PoiNtEr->: Turn your laptop screen off with a keyboard shortcut in Ubuntu

                             Difference between a dream and an aim. A dream requires soundless sleep, whereas an aim requires sleepless efforts.

Search This Blog

Wednesday, January 11, 2012

Turn your laptop screen off with a keyboard shortcut in Ubuntu




you could turn your laptop screen off by issuing this simple command:

1: xset dpms force off


However, a regression causes this command to turn your screen off only for a brief moment. After a few seconds, your screen will turn back on, on its own. I think this is because kernel is dynamic and load it self automatically after a fix interval of time or in case of any event which bothers it.

To get around this problem we can use this script:



#!/bin/bash
screenOffLockFile=/tmp/screen-off-lock
if [ -f $screenOffLockFile ];
then
rm $screenOffLockFile
notify-send "Screen on." -i /usr/share/icons/gnome/48×48/devices/display.png
else
touch $screenOffLockFile
sleep .5
while [ -f $screenOffLockFile ]
do
xset dpms force off
sleep 2
done
xset dpms force on
fi





Save this script and set it as a shortcut.

have fun...and Save Electricity!!

Reference:http://alexcabal.com/turn-your-laptop-screen-off-with-a-keyboard-shortcut-in-ubuntu-karmic/

No comments:

Post a Comment