Tech Tip: Go Green On Your Screen(saver)

 in

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;"
alt+control+k

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.

______________________

Comments

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
www.sangeek.com

KDE

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

NOOO

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:
http://foss-boss.blogspot.com/2008/11/ride-d-bus-control-your-linux-desk...

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.
Thanks

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).

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState