Site Tools


Hotfix release available: 2024-02-06a "Kaos". upgrade now! [55.1] (what's this?)
New release available: 2024-02-06 "Kaos". upgrade now! [55] (what's this?)
backlightcontrol

I am using fluxbox and wanted to make the brightness-keys work. Here are the 3 scripts I mapped to the brightness keys (~/.fluxbox/keys)

/usr/local/bin/backlight_inc

#!/bin/bash

backlight="/sys/class/backlight/pwm-backlight/brightness"

current=$(cat $backlight)
new=$((current +25))
if [ $new -gt 255 ]; then
   new=255
fi

echo $new > $backlight

/usr/local/bin/backlight_dec

#!/bin/bash

backlight="/sys/class/backlight/pwm-backlight/brightness"

current=$(cat $backlight)
new=$((current - 25))
if [ $new -lt 0 ]; then
   new=0
fi
echo $new > $backlight

use new=3 if you don't want your screen to go black on the lowest setting

/usr/local/bin/backlight_toggle

#!/bin/bash

old_file="/tmp/.old_backlight"

backlight="/sys/class/backlight/pwm-backlight/brightness"

current=$(cat $backlight)

if [ $current -eq 0 ]; then
   cat $old_file > $backlight
else
   echo $current > $old_file
   echo 0 > $backlight
fi

Finally I had to create a udev-rule to make the whole thing work as a normal user (“normal” as in “in the admin group”): /etc/udev/rules.d/99-backlight-permissions.rules

KERNEL=="pwm-backlight" SUBSYSTEM=="backlight" RUN+="/bin/chmod 664 /sys/class/backlight/pwm-backlight/brightness"
KERNEL=="pwm-backlight" SUBSYSTEM=="backlight" RUN+="/bin/chgrp admin /sys/class/backlight/pwm-backlight/brightness"
backlightcontrol.txt · Last modified: 2011/11/05 13:33 by excogitation