UPDATE -- 12 July 2019 --
There's now a nice script for Wayland, and I can use my brightness keys.
The script hack below also would ramp the screen to full brightness when switch landscape to portrait mode (or vice versa) and not respond to the touchscreen-GUI brightness control. So really happy with the Wayland solution.
I needed a few tweaks to make @Redsandro solution work on my ubuntu 18.10 install.
Specifically, the Xauth root workaround doesn't work (thanks for mentioning that @Ivo B!) as the
.Xauthority file no longer exists. To find the new file location:
$ xauth info
Authority file: /run/user/1000/gdm/Xauthority
Therefore we change the relevant line:
-OLD: export XAUTHORITY=/home/redsandro/.Xauthority
+NEW: export XAUTHORITY=/run/user/1000/gdm/Xauthority
Additionally, I also had to change
In total this led to changes on three lines.
In order to debug, I used
rui@chaiX1YG2:/var/log$ $ tail -f /var/log/syslog | grep oled-br
e.g. for the two respective errors I found (Xauthority & eDP)
Jan 16 13:03:01 chaiX1YG2 oled-brightness: Can't open display :0.0
Jan 16 13:03:01 chaiX1YG2 oled-brightness: No protocol specified
Jan 16 13:23:46 chaiX1YG2 oled-brightness: warning: output eDP1 not found; ignoring
Jan 16 13:23:46 chaiX1YG2 oled-brightness: xrandr: Need crtc to set gamma on.
NOTE also, this solution does not work in wayland! As xrandr does not work on wayland. So make sure when you log in, you choose xorg, not wayland),
(A bit unfortunate as for me, firefox touch events only works in Wayland, so I have to choose between the brightness vs firefox touchscroll. Not sure why that is yet).
(This answer would have been a comment but I lack credits.)