A simple thing but one that made me feel quite virtuous. I’ve written a very very simple script that turns off the screen whenever I lock the computer. Should save some energy every time I go to a meeting or off for a cuppa.
For anyone interested, it’s a Perl script which watches for the D-Bus signals from gnome-screensaver. Code is as follows:
my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\"";
open (IN, "$cmd |");
while (<in>) {
if (m/^\s+boolean true/) {
system('/etc/acpi/screenblank.sh')
}
}
Note that it relies you running Linux, using GNOME and there being a screen blanking script ‘/etc/acpi/screenblank.sh‘ (which in turn executes ‘/usr/share/acpi-support/screenblank‘ for every display). Not too much to ask I’m sure
– Edit 8th October 2008:
Since upgrading to Ubuntu Karmic, this script no longer seems to work for a couple of reasons. I’ve not investigated in any detail but I do have a new working script using a slightly different D-Bus signal and a different command to blank the screen. Try this if the one above doesn’t work!
#!/usr/bin/perl
my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'\"";
open (IN, "$cmd |");
while (<IN>) {
if (m/^\s+boolean true/) {
system('xset dpms force off')
}
}