To enable backlight hotkeys on System76 Oryx Pro in Fedora 24.

sudo dnf install xbacklight

***Note: You may need to make edits to SELinux to get this to work correctly if you have SELinux enabled (Permissive will throw the error but allow the action of invoking the script and xbacklight).

Find the file that your hotkey actually edits in the OS. Experiment by cat’ing files found here like in my case:

cat /sys/class/backlight/acpi_video0/actual_brightness

Add these two systemd files to the below path:

cd /etc/systemd/system/
sudo nano xbacklightd.path
sudo nano xbacklightd.service

***Note: Any edits to the path file after a systemd enable command will require a stop of the daemon and a “sudo systemctl reenable xbacklightd.path” to reload the active daemon. You may also need to run a “sudo systemctl daemon-reload”.

Copy the below into xbacklightd.path:

[Unit]
Description=Monitor backlight file for changes

[Path]
PathModified=/sys/class/backlight/acpi_video0/actual_brightness

[Install]
WantedBy=multi-user.target

Copy the below to xbacklightd.service. You will need to change the User name and you may need to change the display number. In my case on the Oryx the Display :1 is the nvidia GPU. You can get a list of your displays by issuing “glxinfo” and looking at the very beginning of the output.

[Unit]
Description=Change backlight setting

[Service]
Type=oneshot
User=dave
Environment="DISPLAY=:1"
ExecStart=/etc/systemd/system/xbacklightd
Restart=no

Now create the script that xbacklightd.service executes:

sudo nano /etc/systemd/system/xbacklightd
sudo chmod +x /etc/systemd/system/xbacklightd

The script:

#!/bin/bash
max=/sys/class/backlight/acpi_video0/max_brightness
level=/sys/class/backlight/acpi_video0/actual_brightness
factor=$(awk '{print $1/100}' <<< $(<$max))

xblevel() { awk '{print int($1/$2)}' <<< "$(<$level) $factor"; }
printf $USER
xbacklight -set $(xblevel)
printf "Backlight Set To: %s%% On Display: '%s'\n" "$(xblevel)" "$DISPLAY"

The script complements of here.

Now enable only the path daemon to start on boot (When a file is edited by the hotkey, the path daemon will execute the service script). And then start the service:

sudo systemctl enable xbacklightd.path
sudo systemctl start xbacklightd.path

Troubleshooting:

sudo journalctl -u xbacklightd.service -f