You are not logged in.
Hello,
I recently got a new laptop at work and I put a fresh Arch on it.
Almost everything works perfectly, but I have one weird issue.
I can control backlight of my display via ACPI; I wrote a simple script for it:
pabre@pbr-laptok:~$ cat /usr/local/sbin/brightness.sh
#!/bin/bash
DEV=/sys/class/backlight/intel_backlight/brightness
MAX=`cat /sys/class/backlight/intel_backlight/max_brightness`
ACT=`cat /sys/class/backlight/intel_backlight/actual_brightness`
MIN=0
STEPS=10
STEP=$((MAX/STEPS))
if [ $1 == "+" ]; then
if [ $((ACT+STEP)) -le $MAX ]; then
echo $((ACT+STEP)) > $DEV
fi
elif [ $1 == "-" ]; then
if [ $((ACT-STEP)) -ge $MIN ]; then
echo $((ACT-STEP)) > $DEV
fi
fi
exit 0I put myself a sudoers entry for it:
root@pbr-laptok:~# cat /etc/sudoers | grep pabre
pabre ALL=(ALL) NOPASSWD: /usr/local/sbin/brightness.sh,/usr/bin/pacman -SyAnd it works like a charm, when run from a terminal:
pabre@pbr-laptok:~$ sudo /usr/local/sbin/brightness.sh -So, my next step was to bind that script to appropriate keys on my keyboard (Fn + UP/DOWN - which are XF86MonBrightnessUp and XF86MonBrightnessDown)
My window manager is Awesome, so I put to the config:
...
awful.key({ }, "XF86MonBrightnessUp", function () awful.util.spawn("sudo /usr/local/sbin/brightness.sh +") end),
awful.key({ }, "XF86MonBrightnessDown", function () awful.util.spawn("sudo /usr/local/sbin/brightness.sh -") end),
...among others like touchpad toggling, volume control, etc (which are working without issues)
And now, guess what... Those keys fire that script, change the brightness and after second or less - it comes back to old value! You can see that display blinks (for example gets brighter and moment after - it goes back to previous state).
I tried to debug it, putting to the script something like:
if [ $1 == "+" ]; then
...
if [ $((ACT+STEP)) -le $MAX ]; then
echo $((ACT+STEP)) > $DEV
cat /sys/class/backlight/intel_backlight/actual_brightness >> /tmp/br.log
sleep 1
cat /sys/class/backlight/intel_backlight/actual_brightness >> /tmp/br.log
fi
...And the first entry was that what it was supposed to be, while te other (second after) Was again the old value.
Does anybody have any idea what "reverts" my changes to the /sys/class/backlight/intel_backlight/brightness and why it works without issues when simply run from a terminal?
Last edited by PaBre (2014-03-16 17:10:54)
Offline
I think that I've found partial answer.
When I changed key binds to another keys - it works!
But even then, when I press XF86MonBrightnessUp or XF86MonBrightnessDown, the brightness level gets reset. And now they are not bind to anything (at last not explicit).
So it looks that I have to found how to decouple the internal, not working as expected, bind to these keys.
Offline