I've tried the solution at Ubuntu 19.04 cannot change brightness on laptop but it doesn't seem to be working for me. I am using Ubuntu 19.10 instead of 19.04 as in that answer.
The main script xps-brightness.sh
from that answer:
#!/bin/sh
# Where the backlight brightness is stored
BR_DIR="/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight"
test -d "$BR_DIR" || exit 0
MIN=0
MAX=$(cat "$BR_DIR/max_brightness")
VAL=$(cat "$BR_DIR/brightness")
if [ "$1" = down ]; then
VAL=$((VAL-6000))
else
VAL=$((VAL+6000))
fi
if [ "$VAL" -lt $MIN ]; then
VAL=$MIN
elif [ "$VAL" -gt $MAX ]; then
VAL=$MAX
fi
PERCENT=`echo "$VAL / $MAX" | bc -l`
export XAUTHORITY=/home/derek/.Xauthority # CHANGE "user" TO YOUR USER
export DISPLAY=:0.0
echo "xrandr --output eDP-1 --brightness $PERCENT" > /tmp/xps-brightness.log
xrandr --output eDP-1 --brightness $PERCENT
echo $VAL > "$BR_DIR/brightness"
When I use the brightness keys on my keyboard, both the value in $BR_DIR/brightness
and the /tmp/xps-brightness.log
log file get updated, but the script doesn't seem to execute the xrandr --output eDP-1 --brightness $PERCENT
command. This command works when I enter it directly into a console or in a script such as test.sh
#!/bin/sh
xrand --output eDP-1 --brightness .7
and then run sh test.sh
.
Why doesn't xps-brightness.sh
work?