Updated: September 3, 2021
For those of you blessed with OCD, come closer. Say you're using the Plasma desktop, as you should, and then, unfortunately something goes a-wonk. You need to restart your Plasma shell, which is a relatively simple thing to do. Upon the shell restart, you realize that your system tray icons have rearranged themselves almost randomly, and the expected order of things is gone. Chaos!
I encountered this on a Kubuntu 18.04 box just recently. I then also realized that there isn't a way to pin icons to specific location in the system tray, as in Wireless always to the right, then Volume, then Vaults, etc. So if you expect things to be mega-cushty and consistent, you sure don't want them to change should you ever restart your Plasma shell. In this little guide, I'd like to show you a relatively simple trick of getting icons placed just as you like them. Follow me.
How to create the problem
The easier way to check whether your system tray is going to rebel on you is to restart the Plasma shell via Krunner. Alt + F2, then:
killall plasmashell && kstart plasmashell
The system tray icon may change their left-to-right or right-to-left order.
How to undo it
The trick is to hide and then show icons in a specific order. Right-click on the System Tray expand icon, and select Settings. Then, under Entries, simply hide all of the icons that are you currently shown (either permanently set that way or auto). Once you have hidden them, apply the change, and then, one by one, unhide them in the order you'd like them to be shown in the tray. Say Volume, Network, Clipboard, Vaults, etc. The order and the actual entries are entirely your choice.
Do note that once you set a permanent view, any icons that are set to 'auto' will disappear on inactivity after a while, and show up later when the specific function or application is called, but then, their position will be set to the far left of the system tray. This means, for best results and minimal OCD disruptions, you should only order the position of icons that are always shown. And that settles the chakras, all right. To wit:
Sometimes, simply little things can be maddening - like the icon order in the system tray. Funnily enough, in Windows, the same thing will happen if you restart explorer.exe. The system tray icons will show out of order, and some may disappear altogether, and you may need a reboot to go back to how you want it. In Plasma, if the shell decides to misbehave, restarting the system can help you prevent the icon order disruption, or if you don't wish to reboot, you can then pin-order icons manually if they get disrupted on the shell restart.
I'd like to see this functionality added to Plasma. The simplest thing would be to create a lock/unlock option for the tray, similar to the entire panel, and then allow the users to drag & drop the icons as they like. Again, very similar to how it's done with the application shortcuts, or any other widget on the panel. Until then, this OCD-approved tutorial should keep your demons at bay. And we're done.