Nagstamon Opening Twice on KDE Plasma login
For quite a while I've been having an issue where Nagstamon opens twice on my Fedora laptop ( edit: also just had this problem on my Gentoo desktop ) when I login. I've finally gotten around to investigating it properly and found the cause and a solution.
First of all - the problem: I have Nagstamon set to run on login automatically, and since Nagstamon updated a while ago whenever I logged in I would get a popup with default settings ( no servers configured, the status showing as an overlay instead of in the system tray etc ), as well as the normally configured Nagstamon in my system tray.
![Error message showing no servers configured in Nagstamon](/2022/12/12/nagstamon-opening-twice-on-kde-plasma-login/login-error.png)
I previously tried experimenting by removing the ~/.config/autostart/nagstamon.desktop
file, but that just made both instances of Nagstamon stop loading on startup. Manually running nagstamon
only opened
one instance of Nagstamon, and adding ~/.config/autostart/nagstamon.desktop
back in ( or adding it to run on login in system settings ) made one instance start up on the next login, but went back to two on
further logins.
I also noticed that the second nagstamon process was being run with different arguments:
![pgrep output showing two processes, one of them with a -session argument](/2022/12/12/nagstamon-opening-twice-on-kde-plasma-login/pgrep.png)
and a new directory was being created as ~/-session
:
![contents of the session directory](/2022/12/12/nagstamon-opening-twice-on-kde-plasma-login/session-dir.png)
This helped me understand the problem - by default Plasma restores the previous session, and seems to run previous commands with an extra argument. Digging around further, I eventually found a Github issue referencing the problem and mentions a code change that likely caused it to suddenly appear one day.
Once I understood this, the solution was simple - either disable restoring of sessions, or just exclude nagstamon from the applications restored.
![Plasma settings, add the string nagstamon to the "Don't restore these applications field", or select "Start with an empty session"](/2022/12/12/nagstamon-opening-twice-on-kde-plasma-login/settings.png)
And of course add Nagstamon back to being run on login:
![Autostart applications in Plasma settings](/2022/12/12/nagstamon-opening-twice-on-kde-plasma-login/settings-autostart.png)