I have shortcut/Fn keys to Suspend, Hibernate, Lock the screen, Increase/Reduce Brightness etc… in my laptop. When power goes off, first thing I usually do is try to turn the display off to save power. Well – there’s no keyboard shortcut for putting the display to sleep or turn it off. I have to either run
xset dpms force off or create a custom shortcut key and assign this command to it.
Instead, I’ve been thinking about adding a button to the gnome-power-manager. When I click on that, essentially my display will turn off. Further, I figured out I’ll have to use
DPMSForceLevel (3) from manpages. There are already two icons, for Suspend and Hibernate, and I thought their implementation details might help.
So this morning, when I woke up, I directly went to the computer, downloaded the gnome-power-manager tar ball and started to look at the code. I must appreciate the fact that how clean the code is, and it was a breeze to extend the existing functionality. Surprisingly, the DPMS functions were already implemented. I just had to add a MenuItem to the Tray Icon, add the callback functions in place, and call “gpm_manager_blank_screen”.
And here is the outcome: