How to Add a Command at KDE Startup

Hi
Switching from Ubuntu Gnome to OpenSuse Tumbleweed, with KDE GUI.
I have a backlit keyboard, which using Xorg, I can use the command

xset led 3

to activate the lighting.

In gnome, I usually add the command

/bin/usr/xset led 3 

at startup, so that every time I log in, the lighting activates automatically.

But I’m not getting the same with the KDE interface.

I would like to know how to add this command to boot with the system or on login, as in gnome.

You can pack it as Script, make it excutable and use this Script in systemsettings5-----Startup and Shutdown------Autostart

My Script for starting akonadi not so fast:

#!/bin/bash
sleep 30
/usr/bin/akonadictl restart

I presume you want to run the above command regardless which system you are booting into. Use a systemd service. It will work with any GUI and any distribution:

karl@erlangen:~> systemctl cat --user save-jalbum-settings.service  
**# /home/karl/.config/systemd/user/save-jalbum-settings.service**

[Unit] 
Description=Save jAlbum Project Files 

[Service] 
ExecStart=/bin/bash /home/karl/bin/save-jalbum-settings.sh 

[Install] 
WantedBy=default.target 
karl@erlangen:~> 
karl@erlangen:~> systemctl status --user save-jalbum-settings.service  
**●** save-jalbum-settings.service - Save jAlbum Project Files 
     Loaded: loaded (/home/karl/.config/systemd/user/save-jalbum-settings.service; enabled; vendor preset: disabled) 
     Active: **active (running)** since Sat 2022-05-21 08:31:38 CEST; 3h 9min ago 
   Main PID: 1277 (bash) 
      Tasks: 2 (limit: 4915) 
     Memory: 1.5M 
        CPU: 409ms 
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/save-jalbum-settings.service 
             ├─  1277 /bin/bash /home/karl/bin/save-jalbum-settings.sh
             └─ 12620 sleep 60

Mai 21 08:31:38 erlangen systemd[1267]: Started Save jAlbum Project Files. 
karl@erlangen:~> 

Hi and welcome to the Forum :slight_smile:
Is this a laptop, normally there is a function key for this? If a laptop, then something is not working properly… I have a HP here and Fn+F5 turns the backlight off and on…

Go to KDE System Settings -> Startup and Shutdown -> Autostart. Add your startup script here to have it run on login.

Thank you very much.

This worked perfectly for me.

I created a file called .turn_backlight_at_keyboard.sh with the following content:


#!/bin/bash
usr/bin/xset led 3

I added it to KDE Autostart as in the suggested path and as soon as I logged in the LEDs lit up. It was exactly what I needed.

Well, this solution seems even more elegant than the one I currently use.

But I didn’t understand how I would create this service in systemd.

Do you have an article on the subject, or a step by step?

I appreciate the suggestion.

Thanks.

Well, in fact I use a laptop, but I use it connected to the mouse and keyboard.

The lights are from this keyboard in question, and yes, it has an on and off key. The Scroll Lock.

What happens is that when activating the leds by the key, it blocks some functions, in some applications.

An example is LibreOffice Calc.

I work with some sheets and it’s hard to move around them with Scroll Lock on.

So I looked for a way to activate without the need for the key.

User services go to $HOME/.config/systemd/user: Understanding Systemd Units and Unit Files | DigitalOcean

Thanks, I’ll try to embed this in my system.