KDE Login Script


In Startup and Shutdown > Autostart > Applications I’ve got a matray app, starting successfully:

~/.config/autostart ᐅ cat org.moson.matray.desktop 
[Desktop Entry]
Exec=/usr/bin/matray --delay
Comment=A Manjaro Linux announcements notification app

I’ve been trying to put in Startup and Shutdown > Autostart > Login Scripts my own script:

~/.config/autostart ᐅ cat ibus.sh
#!/usr/bin/env bash
exec ibus-daemon -drxR

its *.desktop:

~/.config/autostart ᐅ cat ibus.sh.desktop 
[Desktop Entry]

The ibus script won’t autorun, though it can be successfully started manually:

~/.config/autostart ᐅ ./ibus.sh

What do I have to do?

You can find the directory where the generated service files for autostart scripts are saved and check their status to find their log.
These generated service files are stored in $XDG_RUNTIME_DIR/systemd/generator.late
you should be able to see the script that you created there.

The service file name for a script names test.sh would look like app-test.sh@autostart.service

Once you have found the file you are looking for use the following command to see its status
systemctl status --user "app-bookMyShow@autostart.service"
You should be able to see the log there. This should give you enough information to see why it’s not working

/run/user/1000/systemd ᐅ ls generator.late 
'app-geoclue\x2ddemo\x2dagent@autostart.service'   app-org.moson.matray@autostart.service          'app-snapshot\x2ddetect@autostart.service'
 app-kaccess@autostart.service                    'app-pamac\x2dtray@autostart.service'            'app-snap\x2duserd\x2dautostart@autostart.service'
 app-klipper@autostart.service                    'app-pamac\x2dtray\x2dbudgie@autostart.service'   xdg-desktop-autostart.target.wants
 app-msm_kde_notifier@autostart.service           'app-pamac\x2dtray\x2dplasma@autostart.service'
 app-org.kde.kdeconnect.daemon@autostart.service  'app-print\x2dapplet@autostart.service'

No service for ibus.sh, right?


Did you add the login script through system-settings autostart? Because the desktop file that you provided looks very different compared to the one’s that were generated on my system. Are you sure you didn’t manually create that desktop file?

why do you have ibus.sh inside ~/.config/autostart?
when adding a script to autostart through kde systemsettings, the script that you are selecting could be placed anywhere. I usually place them in ~/Documents .

did you log out and log in before checking if it was generated?

Exactly. I even have a suspicion why the generated desktop file is so different: because it’s been created yesterday, and not a couple of years ago. Today’s installation has already given me a lot of headache as it is.

I put the script in autostart directory so it should not litter such places as Documents. While it is negotiable, it should not be the cause of my trouble.

No, I can’t tell exactly when the desktop file was generated. I suppose right after pressing OK on the Properties dialog of the script in Startup and Shutdown > Autostart.

Just tried an autostart script with the name ibus.sh . Service file wasn’t generated. Can you try a different file name other than ibus.sh?

Interesting! By the way, do I have to set +x permissions to the script?

Kde systemsettings will tell you if the script doesn’t have executable permissions and allow you to make it executable with just a click of a button.
Yes the executable permission is necessary.

Changed the name of the script to layout.sh. Added it to Startup and Shutdown > Autostart > Login scripts. The same result: desktop generated, but not the service.

Service file will only be generated on login. Did you logout and login back?

Of course I did.

I tested with the name layout.sh and it didn’t work I have no idea how its happening :exploding_head: .
Can you test with ibee.sh ?

I will, I’m in no position to be too choosy :slight_smile: . I can see a cryptic dropdown box under Properties > Application > Advanced Options: D-Bus registration. It’s None with the working matray too, but it looks very suggestive just the same.

Now it’s kinda better:

~/.config/autostart ᐅ ls -al /run/user/1000/systemd/generator.late | grep ibee
-rw-r--r-- 1 alexey alexey 411 Nov 14 08:32 app-ibee.sh@autostart.service

The service, though, shows up in the tray for a brief moment, then dies. I have to restart it manually like this:

~/.config/autostart ᐅ ./ibee.sh 

Now use systemctl status command to check its log
systemctl status --user "app-ibee.sh@autostart.service"

ᐅ systemctl status --user "app-ibee.sh@autostart.service"
× app-ibee.sh@autostart.service - ibee.sh
     Loaded: loaded (/home/alexey/.config/autostart/ibee.sh.desktop; generated)
     Active: failed (Result: timeout) since Mon 2022-11-14 08:32:52 MSK; 9min ago
       Docs: man:systemd-xdg-autostart-generator(8)
    Process: 902 ExecStart=/home/alexey/.config/autostart/ibee.sh (code=exited, status=0/SUCCESS)
   Main PID: 902 (code=exited, status=0/SUCCESS)
        CPU: 3.216s

Nov 14 08:32:47 gaucho systemd[623]: Starting ibee.sh...
Nov 14 08:32:52 gaucho systemd[623]: app-ibee.sh@autostart.service: start operation timed out. Terminating.
Nov 14 08:32:52 gaucho systemd[623]: app-ibee.sh@autostart.service: Failed with result 'timeout'.
Nov 14 08:32:52 gaucho systemd[623]: Failed to start ibee.sh.
Nov 14 08:32:52 gaucho systemd[623]: app-ibee.sh@autostart.service: Consumed 3.216s CPU time.

systemctl start --user "app-ibee.sh@autostart.service"

Yes, it does start successfully.

It looks like on login matray is killing ibee. One icon is replacing another :slight_smile: . Maybe, a delay or something is in order?

yeah you can try a delay using

sleep 20;
exec ibus-daemon -drxR