Keyboard lights: Run script on login (or boot)

Hi,

I’m a linux novice. I’ve recently install on a VM Fedora 39 Workstation.

I have a CMStorm keyboard that lights up/off with the scroll lock key which doesn’t seem to work with the installation. My goal is to have the keyboard lights turn on, at least when I start the session.

On Linux Mint it was relatively easy as I would simply add a startup command through the UI (“Session and Startup”) to run “xset led 3”.

On Fedora I’ve been running the following command:

sudo sh -c 'echo 1 > /sys/class/leds/input1::scrolllock/brightness'

I’ve placed that command in a script in “/usr/bin”, which works when run in the terminal, and I’ve tried initially creating a systemd service to run at boot. When that didn’t work, I removed the service tried creating a user systemd service.

My boot service was defined as:

[Unit]
Description=Service to activate keyboard lights.

[Service]
Type=oneshot
ExecStart=/bin/bash /usr/bin/activate_keyboard_lights.sh

[Install]
WantedBy=multi-user.target

My user service was defined as:

[Unit]
Description=Service to activate keyboard lights.

[Service]
#Type=simple
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/bash /usr/bin/activate_keyboard_lights.sh

[Install]
WantedBy=default.target

With the boot service nothing happened. On login with the user service, nothing happened and status logs show messages related to “bus not found” which detailed messages show that it’s probably related to permissions. I’m guessing because of the need to use sudo.

I’ve also tried running both the script and the command as a keyboard short cut binded to F4, but nothing seems to happen.

Any tips or ideas or should I try get used to manually running the script when I log in?

Thanks.

1 Like