noblank: A Generic Screensaver Preventer
A while ago, I posted an extremely simplistic script for preventing screensaver activation while using gxine. Ever since then, I've felt increasingly embarrassed about leaving a more generic version as "an exercise for the reader". It's time to make amends.
I call the following script noblank. (I also considered calling it noss.) It should be used similarly to nohup. For example, to avoid an annoying interruption while watching a movie:
noblank mplayer dvd://The beauty of this solution is that it can also be used while leisurely reading a good book:
noblank acroread Alice_in_Wonderland.pdf
And so, without further ado, I present noblank (download file):
#!/bin/bash kscreensaver=$(dcop kdesktop KScreensaverIface isEnabled 2>/dev/null) if [ -n $kscreensaver ]; then dcop kdesktop KScreensaverIface enable false &>/dev/null fi (exec "$@")& PID=$(jobs -p) ( while [ -d /proc/$PID ] &>/dev/null ; do xscreensaver-command -deactivate &>/dev/null gnome-screensaver-command --poke &>/dev/null done if [ -n $kscreensaver ]; then dcop kdesktop KScreensaverIface enable $kscreensaver &>/dev/null fi )& wait $PID
Update: 27 Aug 2006 I've uploaded a new version of my script.