Screen brightness
Getting Brightness Keys to work
If you can't get the XF86 Key Events for your screen brightness keys to work, the following script provides a good workaround. It may need some adaption for your system though. (Especially the max_brightness values may vary.) Depending on what value your system uses as max_brightness you may want to use different values for the three parameters declared at the beginning.
#!/bin/bash
base_dir=/sys/class/backlight/intel_backlight # adjust as needed
max_brightness=$(cat ${base_dir}/max_brightness)
lower_threshold=1001 # the brightness does not change linearly. Make smaller steps below this value
small_step=100 # Small increment below lower threshold
large_step=500 # Standard increment above lower threshold
if [ $# -eq 0 ]; then
cp ${base_dir}/max_brightness ${base_dir}/brightness;
elif [ $# -eq 1 ]; then
current_brightness=cat ${base_dir}/brightness;
new_brightness=$current_brightness;
if [ $1 = 'up' ] && [ $current_brightness -lt $lower_threshold ]; then
new_brightness=expr $current_brightness + $small_step;
elif [ $1 = 'up' ] ; then
new_brightness=expr $current_brightness + $large_step;
elif [ $1 = 'down' ] && [ $[ $current_brightness - $small_step ] -lt $lower_threshold ]; then
new_brightness=expr $current_brightness - $small_step;
elif [ $1 = 'down' ] && [ $[ $current_brightness - $large_step ] -lt $lower_threshold ]; then
new_brightness=$lower_threshold;
elif [ $1 = 'down' ] ; then
new_brightness=expr $current_brightness - $large_step;
else
new_brightness=$1;
fi
echo "New brightness: $new_brightness";
if [ $new_brightness -lt 0 ]; then
new_brightness=0;
elif [ $new_brightness -gt $max_brightness ]; then
new_brightness=$max_brightness;
fi
echo $new_brightness > ${base_dir}/brightness;
else
echo "Usage: basename $0 {brightness}";
echo "No argument gives maximum brightness";
exit -1;
fi
N.B: You can view the max_brightness value on your system with
cat /sys/class/backlight/intel_backlight/max_brightness
Now since you need root privileges to write the brightness value into the pseudo-file, run the script with sudo and make it password free in the sudoers file (which you can open with visudo)
ALL ALL = NOPASSWD: /usr/local/bin/screen_backlight
Finally, map the commands
sudo /usr/local/bin/screen_backlight up
and
sudo /usr/local/bin/screen_backlight down
to the keyboard shortcuts you want.