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.

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:

and a new directory was being created as ~/-session
:

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.

And of course add Nagstamon back to being run on login:
