Tech Tip: Go Green On Your Screen(saver)


I usually lock my screen when I leave my cubicle for a tea-break etc. With all the talk of saving energy these days I've disabled screen-savers on my system. Still, when I'd lock my screen I noticed that the LCD didn't turn off completely. Wanting to go as green as I could I wanted to switch off the LCD as well.

The following command does that:

  xset dpms force off

When I press "Alt+Ctrl+L" (lock screen), the following command is invoked:

  gnome-screensaver-command --lock

What I want now is to associate the following command with a different shortcut key:

   gnome-screensaver-command --lock; xset dpms force off

So that I can lock as well as power off my LCD screen with a keyboard shortcut. To do this I installed xbindkeys to add a custom shortcut key. When you have xbindkeys installed create created the default config file:

  xbindkeys --defaults > /home/your-user-name/.xbindkeysrc

Now assign a shortcut key. To do this you edit the config file (or if you prefer you can install xbindkeys-config) and append the following lines to the file:

# lock&blank
"gnome-screensaver-command --lock; sleep 1; xset dpms force off;"

You also should remove all the enabled lines (comment them out), at least in my case they somehow interfered with my other shortcuts. I also had to add the sleep 1 between the commands to get it to work, perhaps due to compiz animation time.

Now, when I press "alt+control+k" I save power as well as lock my screen.

Tested on Ubuntu 8.10 running on Lenovo T61p.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Why do screen(savers) don't really save ?

k.sangeeth's picture

1. They consume more power than a switched off display(the calculation for this is pretty simple :) )
2. screensavers do consume some amount of CPU cycles.
3. Keeping the display switched on continuously may reduce it's lifetime.

Sangeeth Keeriyadath


Mitch Frazier's picture

For KDE do:

dcop kdesktop KScreensaverIface lock
sleep 1
xset dpms force off

Mitch Frazier is an Associate Editor for Linux Journal.

> For KDE do: > dcop

Antonio's picture

> For KDE do:
> dcop kdesktop KScreensaverIface lock
> sleep 1
> xset dpms force off


Since years ago KDE uses D-Bus, so it should be:
qdbus org.kde.krunner /ScreenSaver org.freedesktop.ScreenSaver.Lock; sleep 2s; xset dpms force off

See more in:

Depends on which version of KDE you're using

Mitch Frazier's picture

If you're using KDE4 then yes, use dbus. If you're using KDE3, which I am, then no, use dcop. I should have mentioned that this was for KDE3.

Mitch Frazier is an Associate Editor for Linux Journal.

works in XFCE too

Mark Pettit's picture

Very neat. I also used the xscreensaver-command -lock;sleep 1;xset dpms force off, saving it into a text file, making it executable, and then configuring that as
a hot-key under XFCE (used linux-key + L). and blow me down, it worked.

I just plugged my lcd's into

lowtech's picture

I just plugged my lcd's into a powerstrip on the desktop. and then jut hit that button. :)

May need to disable gnome-power-manager's backlight handling

Anonymous's picture

Because the current gnome-power-manager's backlight control is completely broken, you may need to disable it by setting /apps/gnome-power-manager/backlight/enable to false in gconf-editor. At least on my laptop gpm kept turning the backlight back on after a minute or so after running xset dpms force off.

You just need to set

ngine13's picture

You just need to set /apps/gnome-power-manager/backlight/idle_brightness to 0. I tested it and works so far. :)

No i'm wrong.. :(

ngine13's picture

No i'm wrong.. :(

it works with xscreensaver too

Anonymous's picture

the same tip can also be done if you use xscreensaver instead of gnome's
even doing $xscreensaver-command -lock; sleep 1; xset dpms force off in a terminal works
I also was looking for a way to turn off my laptop's screen so thanks for the tip :)

You can assign the shortcut

ngine13's picture

You can assign the shortcut key using "Commands" in CompizConfig Settings Manager (in Gnome).