Bug 498397

Summary: Shell autostart not working even after restart/relogin
Product: [Applications] systemsettings Reporter: Thomas Rother <t.rother>
Component: kcm_autostartAssignee: Plasma Bugs List <plasma-bugs-null>
Status: REOPENED ---    
Severity: normal CC: kde, kermit, nicolas.fella, t.rother
Priority: NOR    
Version First Reported In: 6.3.4   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Autostart of shell scripts not working
shell script to add multiple ssh keys for ksshaskpass
kcm_auostart

Description Thomas Rother 2025-01-08 21:03:50 UTC
Created attachment 177210 [details]
Autostart of shell scripts not working

A shell script located in .config/autostart/ with proper permissions can be added in the UI but is never automatically started, even not after a restart.
Comment 1 David Edmundson 2025-01-08 23:12:42 UTC
The ssh-add from your screenshot?

Please check 'journalctl --user -b' for logs for anything relevant.
Comment 2 Thomas Rother 2025-01-09 10:55:03 UTC
Created attachment 177226 [details]
shell script to add multiple ssh keys for ksshaskpass
Comment 3 Thomas Rother 2025-01-09 15:09:06 UTC
thommie@odysseus4:~> journalctl --user -b
Jan 09 09:12:06 odysseus4 systemd-xdg-autostart-generator[2388]: Configuration file /home/thommie/.config/autostart/ssh-add>
Jan 09 09:12:07 odysseus4 systemd[2379]: Configuration file /home/thommie/.config/systemd/user/ssh-agent.service is marked >
[...]
Jan 09 09:12:07 odysseus4 systemd[2379]: Started SSH agent (ssh-agent).

The ssh-agent.service file

[Unit]
Description=SSH agent (ssh-agent)

[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
Environment=DISPLAY=:0
ExecStart=ssh-agent -D -a $SSH_AUTH_SOCK
ExecStop=kill -15 $MAINPID

[Install]
WantedBy=default.target

Hmmm, Question: is it possible that the service comes up a bit too late for the script execution?
Comment 4 Bug Janitor Service 2025-01-24 03:47:16 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 5 Thomas Rother 2025-01-24 08:33:31 UTC
Problem is still visible. Plasma does not start the script even after re-login. Current environment now plasma 6.2.5, frameworks 6.10.0, QT 6.8.1 on openSUSE Tumbleweed
Comment 6 Thomas Rother 2025-01-24 08:35:55 UTC
Created attachment 177640 [details]
kcm_auostart
Comment 7 Thomas Rother 2025-01-28 10:51:18 UTC
Note: kcm_autostart always shows the "ssh-add.sh not yet started automatically", even after a reboot or re-login. But I can successfully start the script manually from the shell

thommie@odysseus4:~> .config/autostart/ssh-add.sh 
Identity added: /home/thommie/.ssh/[xxxxx]
Identity added: /home/thommie/.ssh/[xxxxx]
Comment 8 Thomas Rother 2025-01-28 17:48:41 UTC
maybe just a side effect without relevance for this, just for info:

With a wayland session, the script throws libegl warnings:

thommie@locutus:~> .config/autostart/ssh-add.sh 
libEGL warning: egl: failed to create dri2 screen
libEGL warning: egl: failed to create dri2 screen
Identity added: /home/thommie/.ssh/[xxxx]

This does not happen with an X11 session.  Information for package libnvidia-egl-wayland1:

-----------------------------------------------
Repository     : repo-oss
Name           : libnvidia-egl-wayland1
Version        : 1.1.17-1.1
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 109.7 KiB
Installed      : Yes
Status         : up-to-date
Source package : libnvidia-egl-wayland-1.1.17-1.1.src
Upstream URL   : https://github.com/NVIDIA/egl-wayland
Summary        : The EGLStream-based Wayland external platform
Comment 9 Thomas Rother 2025-02-14 18:02:45 UTC
Just for reference, the issue is referenced on these platforms too:

- https://discuss.kde.org/t/autostart-login-scripts-no-working/11981 (after migration KDE 5.x >> 6.x)
- https://forum.manjaro.org/t/kde-plasma-6-2-4-autostart-not-working/173465 (for Manjaro with Plasma 6.2.4)
Comment 10 Thomas Rother 2025-02-28 09:55:24 UTC
... still open in KDE Plasma 6.3.1, Framework 6.11 on

Distributor ID: openSUSE
Description:    openSUSE Tumbleweed
Release:        20250226

All other autostart settings (Applications ownCloud client and Remmina) work fine, but the shell script is not started upon login. It must be started from shell manually
Comment 11 Thomas Rother 2025-03-21 06:54:16 UTC
Can please someone have a look at this? Its still open since a number or releases and there was no activity on the bug yet since I reported it at 2025-01-08 . See also referenced reports mentioned in https://bugs.kde.org/show_bug.cgi?id=498397#c9 I'd be happy to help with debugging this ...
Comment 12 David Edmundson 2025-03-25 10:55:25 UTC
Can you confirm where this ssh-agent file comes from. That file is wrong.  

We shouldn't hardcode display, and it's not set to startup in the right place, and if you're relying on X it needs to come after graphical-session.target is up to ensure kwin is ready.
Comment 13 Thomas Rother 2025-03-25 14:28:32 UTC
I grabbed the solution from the net, see also other references in #9. The script works fine when started manually from the shell, but not automatically on KDE login. 

If the script itself or something else is wrong and can therefore not be executed, maybe we can fix it together ... ?
Comment 14 Thomas Rother 2025-04-04 06:30:13 UTC
worksforme now
Comment 15 Thomas Rother 2025-04-20 20:50:51 UTC
Reopening. I still have the issue on on two of three machines, although the script itself is the same on all three. 
There are also a number of other reports of peopble that have problems with autologin scripts since plasma 6.x :

https://discuss.kde.org/t/autostart-login-scripts-no-working/11981/18
Comment 16 Thomas Rother 2025-04-21 06:12:43 UTC
(In reply to Thomas Rother from comment #15)
> Reopening. I still have the issue on on two of three machines, although the
> script itself is the same on all three. 
> There are also a number of other reports of peopble that have problems with
> autologin scripts since plasma 6.x :
> 
> https://discuss.kde.org/t/autostart-login-scripts-no-working/11981/18

What I still don't understand: the script works fine after login when started from Konsole but not through the Plasma autostart.
Comment 17 Arek Guzinski 2025-04-24 07:16:45 UTC
For me scripts only work if they start with a shebang (e.g. #!/bin/sh).
I'm pretty sure I already wrote this in a bug report a year or two ago, but don't know which one than was.