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:



xset s off -dpms

dcop kdesktop KScreensaverIface enable false


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! :)

0 comentários:

Post a Comment


template by Ourblogtemplates.com
©Copyright 2009, Cleber de Mattos Casali. All rights reserved.