#1084225 desktop-base: Plasma startup order messes up ssh agent in konsole using shortcuts

#1084225#5
Date:
2024-10-06 20:37:34 UTC
From:
To:
If Konsole is started using krunner ssh-agent works. If Konsole is started
sing a shortcut ssh-agent is broken. This seems to be due to the way the
plasma session is initialised, and it's broken on Debian while Fedora ships
a workaround (voluntary or otherwise).

Steps to reproduce:

- Run Konsole from the application menu
- Run `ssh-agent -l`, see 'The agent has no identities.'
- Open System Settings > Shortcuts > Add Application > Konsole
- Choose a shortcut, apply, then launch Konsole using that shortcut
- Run `ssh-agent -l`, now it throws the error:
     'Could not open a connection to your authentication agent.'

I found someone on stackoverflow lamenting the same behaviour:
https://unix.stackexchange.com/questions/771404/launching-via-plasma-shortcut-removes-ssh-agents-environment-variables

It was confirmed on KDE's bug tracker:
https://bugs.kde.org/show_bug.cgi?id=483541

Quoting Nicolas Fella from the bug report:

=====
What seem to be happening is this:

When launching apps via global shortcuts they are launched from kwin_wayland whereas when they are launched from the app launcher/krunner the launching process is plasmashell/krunner.

When SSH_AUTH_SOCK is populated after kwin_wayland is started it will not be in kwin's environment, so it doesn't propagate to apps launched by kwin.

Fedora ships a file /etc/xdg/plasma-workspace/env/ssh-agent.sh that causes SSH_AUTH_SOCK to be set before kwin starts, so for me on Fedora it works fine.

However on Neon there's no such file so SSH_AUTH_SOCK is not set that way and only later set by something else
=====

It would be nice if Debian had the same workaround

Thanks!