my Dell laptop is subject to this bug with kernel 3.14. As a workaround I wrote a simple script
/usr/bin/brightness-fix:
#!/bin/bash
echo 0 > /sys/class/backlight/intel_backlight/brightnes
(and made executable: chmod +x /usr/bin/brightness-fix
)
and a systemd service calling it that is executed at startup:
/etc/systemd/system/brightness-fix.service
[Unit]
Description=Fixes intel backlight control with Kernel 3.14
[Service]
Type=forking
ExecStart=/usr/bin/brightness-fix
TimeoutSec=0
StandardOutput=syslog
#RemainAfterExit=yes
#SysVStartPriority=99
[Install]
WantedBy=multi-user.target
and enabled: systemctl enable /etc/systemd/system/brightness-fix.service
That works like a charm and I can control my display brightness as wanted.
The problem comes when the laptop resumes after going to sleep mode (e.g. when closing the laptop lip): brightness control doesn't work anymore unless I manually execute my fisrt script above: /usr/bin/brightness-fix
How can I create another systemd service like mine above to be executed at resume time?
EDIT:
According to comments below I have modified my brightness-fix.service
like this:
[Unit]
Description=Fixes intel backlight control with Kernel 3.14
[Service]
Type=oneshot
ExecStart=/usr/local/bin/brightness-fix
TimeoutSec=0
StandardOutput=syslog
[Install]
WantedBy=multi-user.target sleep.target
also I have added echo "$1 $2" > /home/luca/br.log
to my script to check whether it is actually executed.
The script it is actually executed also at resume (post suspend
) but it has no effect (backlit is 100% and cannot be changed). I also tried logging $DISPLAY
and $USER
and, at resume time, they are empty. So my guess is that the script is executed too early when waking up from sleep. Any hint?
WantedBy=sleep.target
.../usr/local/bin
, not/usr/bin
. that directory is reserved for the package manager only.sleep.target
will run the unit when the computer sleeps, rather than when it resumes. See my answer below for a unit file that worked for me with a similar problem.