Skip to content

Optional: Apply settings before login (systemd)

Luke Horwell edited this page Jun 5, 2025 · 1 revision

For systemd-based distributions (like Ubuntu, Arch Linux, etc), it is possible to use the sysfs driver directly to apply settings at boot time, before logging in to the system. This may be useful if your keyboard was left with a zero brightness, or you want the same effect regardless of who last used the computer.

Using the sysfs driver directly is a reliable solution, since the Python library is unavailable without the daemon running. The daemon also cannot be run reliably while logged out since it serves a D-Bus session bus, which is designed for logged in user sessions (not root). This means that you don't need openrazer-daemon or python3-openrazer installed.

This wiki page is merely some guidance on how to accomplish this.

1. Prepare the script

For example, in your /usr/local/bin folder, and mark as executable:

sudo touch /usr/local/bin/openrazer-prelogin.sh
sudo chmod +x /usr/local/bin/openrazer-prelogin.sh

Edit the script and write the sysfs commands to echo here. The script will run as the root user.

sudo nano /usr/local/bin/openrazer-prelogin.sh

The sysfs driver is documented in the wiki:

Here's an example to apply a static green:

#!/bin/bash

# Allow time for the kernel to initialise devices
sleep 2

# Apply a static green (#00FF00) to each compatible Razer device (VID 1532)
for dev in /sys/bus/hid/devices/0003:1532:*/matrix_effect_static
do
    if [[ -w "$dev" ]]; then
        echo -ne "\x00\xFF\x00" > "$dev"
        echo "OK: $dev"
    fi
done

2. Create the systemd service

sudo nano /etc/systemd/system/openrazer-prelogin.service

File contents:

[Unit]
Description=Apply OpenRazer lighting on boot
After=multi-user.target
Requires=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/openrazer-prelogin.sh
RemainAfterExit=true

[Install]
WantedBy=multi-user.target

Then enable/start the service:

sudo systemctl enable openrazer-prelogin
sudo systemctl start openrazer-prelogin

3. Checking status

If things are not working, the output can be checked like so:

sudo systemctl status openrazer-prelogin
Clone this wiki locally