Friday, February 11, 2011

Turn off the Laptop screen.........

Hi,

If you are a guy like me who probably keeps huge downloads in laptop and go out somewhere or if you use your laptop as music player while on battery and wanna turn your screen off to save your battery power, then its necessary for you to know how to turn your screen off.

Some laptop does have a special function key to do the job but for unlucky guys like me who's laptop doesn't have this feature then we have have to find some other way.

When I used to use windows I could find lots of software for doing this job. But then I turned to linux and I couldn't find any useful software. There's simply a command in linux for turning your screen off. It's
xset dpms force off
and it does it's job. But due to a bug in gnome power manager, the screen gets on after a while by itself. After googling for sometime, I came across two scripts that bypasses the regression. They can be found out at http://alexcabal.com/turn-your-laptop-screen-off-with-a-keyboard-shortcut-in-ubuntu-karmic/ and http://monda.hu/blog/2010/01/12/lock-your-laptop-and-turn-off-display-with-the-touch-of-a-keystroke-in-ubuntu-karmic/ .

I tired both the scripts but found some problems in both of them. In the first script, I found two major problems. (1) It doesn't lock your computer. Now it is necessary for me as when I am away from my laptop, I dont want anybody to have access to my files. I need little privacy :) . and (2) My screen was turning on and turning off repeatedly very fast. This was the major problem with that script. The other script lacks the feature of turning the power manager on after we actually wanna turn the screen on. We need to do it manually.

So I decided that I will write my own app for doing the job. You can download the app at
just download the jar file. Then make it executable by using chmod.
chmod 777 Kanta-TurnScreenOff.jar

Now just double click the jar and your screen turns off. For easy access you can even assign a shortcut to the jar file. I first kept the jar at /home/prince/.MySystemTweaks/ ( you can put the jar anywhere) then I went to Preferences -> Keyboard shortcuts in my Pinguy OS. Click on add then give the name of your choice. I gave "turn screen off" and in commands write "java -jar path-to-jar-file" and click apply. So my final command was "java -jar /home/prince/.MySystemTweaks/Kanta-TurnScreenOff.jar" . After that click on disabled and then provide any keyboard shortcut. I gave ctrl+alt+shift+s.

Now just by using shortcut keys , you can turn your screen off.


Thanks.

P.S. - A JRE must be installed for this software to run. I tested it on my Pinguy OS. But it should work without any problems on other linux too.