Turning screensaver on and off in KDE
Sunday, February 15, 2009
One problem that have always bothered me on Linux is the screensaver starting up when you really don't want it. This happens for example when you're watching a movie, or playing a game exclusively on joystick.
This happens because of a combination of two reasons:
1) Both KDE and GNOME do not monitor joystick activity to keep the screensaver from activating. This has been reported as a BUG in Ubuntu.
2) Some applications do not block the startup of the screensaver (RealPlayer, SDLMAME, SDLMESS, games in wine ...)
Well, there is a solution that works very well on my Kubuntu. I have created two small scripts, one to turn off screensaver, and another one to turn it back on:
screensaver-off
#!/bin/bash xset s off -dpms dcop kdesktop KScreensaverIface enable false |
screensaver-on
#!/bin/bash xset s on +dpms dcop kdesktop KScreensaverIface enable true |
Just save these scripts in your directory "/usr/bin/" and give permission to execute:
sudo chmod +x /usr/bin/screensaver-off
sudo chmod +x /usr/bin/screensaver-on
After this procedure, just modify the shortcut of your problematic applications, so they will turn off the screensaver on start, and turn it on again after exit.
For example, the shortcut to your favorite game in SDLMAME, which was:
xmame mygame
will now look like this:
screensaver-off; xmame mygame; screensaver-on
Have fun without having to move your mouse every 10 minutes! :) Read more...