Ubuntu – Ubuntu 19.04 cannot change brightness on laptop

brightnessdellxps

I recently purchased a Dell xps 15 9570 and installed ubuntu 19.04 onto it, removing windows 10. There were a lot of issues with ubuntu not being able to detect certain drivers but I was able to solve them. But one issue I cannot solve is the fact I cannot change the brightness via the functions keys. xbacklight doesn't work, the only way I can change the brightness, is by typing xrandr --output eDP1 --brightness 0.4 into console.

The screen is OLED, also using intel's inbuilt UHD Graphics 630 and not nvidia but I have both.

Best Answer

Ivo's (https://askubuntu.com/users/632873/ivo-bl%c3%b6chliger) solution at Lenovo ThinkPad X1 Yoga OLED Brightness for a Yoga laptop also works for the Dell XPS 15-9570. The only thing I had to change was to subtract/add 6000 instead of the 71 in the script. That gives me a 20 step change, i.e. up/down by 5% for every key press.

This is what the modified solution looks like for the XPS 15, using similar three files. The first one is /etc/acpi/events/xps-brightness-up:

event=video/brightnessup BRTUP 00000086
action=/etc/acpi/xps-brightness.sh up

nuber two is /etc/acpi/events/xps-brightness-down:

event=video/brightnessdown BRTDN 00000087
action=/etc/acpi/xps-brightness.sh down

and then the main script /etc/acpi/xps-brightness.sh:

#!/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/user/.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"

Don't forget to do a chmod a+x /etc/acpi/xps-brightness.sh and restart acpi by typing

sudo service acpid reload

I hope, this helps ;-)

Related Question