This tutorial will teach Linux users how to make a script in order to easily turn off their netbook or laptop's monitor (LCD screens) with a keystroke, to save battery life.Are you using Linux and you want to save the life of your laptop/netbook's battery? Look no further, we have the solution for you! The following guide will teach you step-by-step with screenshots, how to make a script and create a shortcut key in order to easily turn off your LCD screen with a keystroke, to save the life of your notebook's battery.
We've tested this tutorial on the newly released Ubuntu 11.10 Beta 2 (Oneiric Ocelot) operating system and it's working like a charm. Please follow the instructions below carefully.
Step 1 - Install the requirementsFirst of all, we need to install a Python library, so just click the link below and let your package manager install the required package. After installation, close the package manager and proceed to the next step.
Step 2 - Make the scriptNow that you've installed the required library (see above), all you need to do is to right click on your desktop and select the "Create New Document -> Empty Document" option.
monitor_off.sh. Now, open it with a double click, copy the code below and paste it in.
from Xlib import X
from Xlib.display import Display
display = Display(':0')
root = display.screen().root
X.ButtonPressMask | X.ButtonReleaseMask | X.PointerMotionMask,
X.GrabModeAsync, X.GrabModeAsync, 0, 0, X.CurrentTime)
X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)
subprocess.call('xset dpms force off'.split())
p = subprocess.Popen('gnome-screensaver-command -i'.split())
Save the file!
Editor's note: Place the monitor_off.sh file somewhere on your home folder, but remember the path for the next step.
Step 3 - Make the shortcutClick the Ubuntu logo to open the Unity Dash and search "keyboard" (without quotes). Click the "Keyboard" icon and the Keyboard app will open.
/home/softpedia/monitor_off.sh). Click the "Apply" button when you're done.
If you encounter issues with the tutorial, do not hesitate to drop a comment below. Have fun using Linux!