[SOLVED] Disable KDE4 screensaver while watching a movie
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.