Control your Laptop Brightness Using Keyboard Shortcuts

I have prepared a python script which you can use to control brightness of your laptop. Download brightness.py and save the file some where on your system.

Install xbindkeys to map keyboard shortcuts.

sudo apt-get -y install xbindkeys

Execute following command to initialize your xbindkeys configuration file.

xbindkeys --defaults > ~/.xbindkeysrc

Now copy and paste following snippet at the end of your .xbindkeysrc file.

"python [script path]/brightness.py down"
m:0x5 + c:100
Control+Shift + Left

"python [script path]/brightness.py up"
m:0x5 + c:102
Control+Shift + Right

Make sure you replace [script path] with the path of the folder that contains downloaded python script. Open up your terminal and execute following command to start xbindkeys.

xbindkeys &

Now test your shortcut keys Control+Shift+Left Arrow and Control+Shift+Right Arrow. Make sure you add xbindkeys command to ubuntu sessions so that xbindkeys is automatically started every time you login.

Enjoy ubuntu :)

Comments

Caner said…
The script gives errors on Ubuntu 9.10.

It says:
Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PowerManagement was not provided by any .service files
Laptop Service said…
This is simply great and certainly it will help users. I am looking forwarding to download this file and use the keyboard shortcuts for brightness and other functions.
Unknown said…
I'm trying to get this neat script working on my cr-48 but keep getting this error on both up and down. Any help would be greatly appreciated!

$ python /usr/share/doc/xbindkeys/brightness.py down
/usr/share/doc/xbindkeys/brightness.py:12: DeprecationWarning: os.popen2 is deprecated. Use the subprocess module.
out = os.popen2("dbus-send --type=method_call --print-reply --dest=org.freedesktop.PowerManagement --session /org/freedesktop/PowerManagement/Backlight org.freedesktop.PowerManagement.Backlight.GetBrightness")[1].read()
Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PowerManagement was not provided by any .service files
Traceback (most recent call last):
File "/usr/share/doc/xbindkeys/brightness.py", line 36, in
brightness_down()
File "/usr/share/doc/xbindkeys/brightness.py", line 26, in brightness_down
val = get_brightness()
File "/usr/share/doc/xbindkeys/brightness.py", line 13, in get_brightness
val = re.findall("uint32.(\d+)", out)[0]
IndexError: list index out of range

Popular posts from this blog

Easy network traffic shaping on your ubuntu system

Multi touch for any,all synaptics touchpad

winetricks - install wine application perquisites with ease