LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices



Reply
 
Search this Thread
Old 07-27-2013, 01:06 AM   #1
laitcg
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Rep: Reputation: 3
Lightbulb Disable KDE4 screensaver while watching a movie


My KDE screen saver is set for 15 minutes and this bash script is in my Autostart for KDE4.

It simulates user activity every 10 minutes vice disable/enable the screensaver.

It uses a single line of program names separated by spaces. Enjoy.

Code:
#!/bin/bash
# Copyright 2013, Jack S. Lai, Waianae, HI
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Place this script in your KDE Startup. My Screen saver is set for 15 min.

# Space seperated list of programs to look for:
programs="vlc mplayer"
# Add your browser EG: 'firefox' if you use it for flash movies

sleep 600	# wait 10 minutes to check as we just started KDE
for pgm in ${programs}; do	# Check list of programs one by one
     if ps axo comm | grep -q ${pgm} ;then # Is a program running?
	# Yes, simulate user activity vice shutting down the screen saver
	qdbus org.kde.screensaver /ScreenSaver SimulateUserActivity
	break	# All done, we had at least one program running.
    fi
done
exec $0 $*	# Restart this script

Last edited by laitcg; 07-27-2013 at 01:11 AM.
 
Old 07-27-2013, 09:48 AM   #2
jdackle
Member
 
Registered: Apr 2010
Distribution: Debian, LMDE
Posts: 46

Rep: Reputation: 11
Nice script!

But I'm replying on the subject of the copyrights.
I've done a similar set of scripts (with the help of xl) and posted it here: http://www.linuxquestions.org/questi...ns-4175468270/ (current scripts at post #5).
They're meant to be used with XFCE, not KDE and intended to prevent the computer from suspending (not blanking the screen, for my purposes kepping the screensaver active is actually a good thing). But the rational is basically the same as for your script.

I can still work a lot on it and one thing I was thinking about is the way it checks for active programs that should prevent the computer from suspending. I'm doing it through an "if ( pgrep -l program1 ) || ( pgrep -l program2 ) || ..." condition but your way seems much more efficient.

So my question is: can I just take that part of your script (the "programs="prog1 prog2" + modified "for" loop) and add a modified "copyright" notice after what I currently have, such as (proposed addition in bold):
Code:
# Script suggested by user "xl" at LinuxQuestions.org in reply to a question of mine (JDAckle):
#  XFCE (or related) Power Management "Inactivity" Settings/Exceptions 
# http://www.linuxquestions.org/questions/linux-desktop-74/xfce-or-related-power-management-inactivity-settings-exceptions-4175468270/
# 02/07/2013 to 07/07/2013
# Process-running check modified according to the way Jack S. Lai coded his own  "Disable KDE4 screensaver while watching a movie" script, posted at http://www.linuxquestions.org/questions/linux-desktop-74/disable-kde4-screensaver-while-watching-a-movie-4175471090/#post4997687 (27/07/2013, 06:06 GMT
Thank you kindly,
Jean D. Ackle
 
Old 07-27-2013, 04:12 PM   #3
laitcg
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by jdackle View Post
Nice script!

So my question is: can I just take that part of your script (the "programs="prog1 prog2" + modified "for" loop) and add a modified "copyright" notice after what
You can take any PART of the script as needed w/out copyright inclusion. The script as a whole is the only thing copyrightable. But I do appreciate the mention

Last edited by laitcg; 07-27-2013 at 04:18 PM.
 
1 members found this post helpful.
Old 07-27-2013, 06:19 PM   #4
jdackle
Member
 
Registered: Apr 2010
Distribution: Debian, LMDE
Posts: 46

Rep: Reputation: 11
Thank you!
Will be glad to make the mention!

EDIT: Done!

Last edited by jdackle; 07-29-2013 at 12:21 PM.
 
Old 10-31-2013, 02:32 PM   #5
laitcg
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Original Poster
Rep: Reputation: 3
v1.1 10/31/13 - added "--sort -pcpu" to make the search quicker.

Code:
#!/bin/bash
# Copyright 2013, Jack S. Lai, Waianae, HI
# All rights reserved.
#
# v1.1 10/31/13 - added "--sort -pcpu" to make the search quicker.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Place this script in your KDE Startup. My Screen saver is set for 15 min.

# Space seperated list of programs to look for:
programs="vlc mplayer"
# Add your browser EG: 'firefox' if you use it for flash movies

sleep 600	# wait 10 minutes to check as we just started KDE
for pgm in ${programs}; do	# Check list of programs one by one
     if ps axo comm --sort -pcpu | grep -q ${pgm} ;then # Is a program running?
	# Yes, simulate user activity vice shutting down the screen saver
	qdbus org.kde.screensaver /ScreenSaver SimulateUserActivity
	break	# All done, we had at least one program running.
    fi
done
exec $0 $*	# Restart this script
 
  


Reply

Tags
autostart, bash, kde, media, screensaver


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Does someone REALLY know how to disable the &&(#_)@(**&%*%#@# screensaver in KDE4? jlinkels Debian 11 07-05-2011 11:53 AM
Watching a movie in ASCII Art Alexvader Slackware 11 01-28-2010 10:58 AM
Screensaver appears while watching DVD Rockgod1969 Linux - Software 6 03-03-2007 05:58 AM
Screensaver opening while I'm watching movies Ironica Linux - Software 2 06-04-2004 11:48 AM
Can't get any color when watching movie Coume Linux - Software 3 05-26-2004 01:04 PM


All times are GMT -5. The time now is 10:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration