Is there a way to set a hotkey to change screen brightness? [duplicate]

Possible Duplicate:
How to change the shortcut to adjust brightness?

The brightness keys on my laptop are not recognized by Ubuntu, which is a common problem for a variety of laptops, is there a way to set an arbitrary key shortcut to change brightness in Ubuntu 12.04? I looked in the Keyboard settings app under the shortcut tab, and I couldn't find one.

I am able to set brightness in the Brightness and Lock settings app, but it would be much more convenient if I could just assign a key shortcut, like Ctrl+F2 and Ctrl+F3.


Solution 1:

This is a generic way to set arbitrary brightness up/down keys on Ubuntu 12.04 using the Keyboard settings app.

sudo apt-get install xdotool

Open "Keyboard" settings app, go to Shortcut tab, click Custom Shortcut, then the little + button to add a shortcut.

name: Brightness Up
command: xdotool key XF86MonBrightnessUp

and another:

name: Brightness Down
command: xdotool key XF86MonBrightnessDown

Click where it says "Disabled" and then hit the key-combo you want, I ended up using F2 and F3.

In Ubuntu 16.04 use --clearmodifiers with the command, i.e.,

name: Brightness Up command: xdotool key --clearmodifiers XF86MonBrightnessUp

and

name: Brightness Down command: xdotool key --clearmodifiers XF86MonBrightnessDown