Plasma desktop secrets: system area icon spacing

 

Overall, I’m mighty pleased with the Plasma desktop. But come
version 5.16, y’know, two versions behind the most recent one –
Plasma 5.18 LTS, there have been a few less-than-ideal
changes, mostly tiny visual things that make the desktop less sharp than before. Again, since the
desktop evolves quite rapidly, by the time you read this, we might all be using flying cars and atomic
refridgerators and talk to AI assistants like all the time. Or not really.

Well, one of the things I find less nice in the new more-touchy more-plasticky Plasma of recent is
that the system area icon spacing is a bit off. Less than ideal. The icons sit too close to one
another. So I got me thinking, how does one edit this? Well, the answer isn’t trivial, hence this
article. Begin to explore!

Problem in more detail

Let’s demonstrate with some fine imagery.
Plasma 5.12 LTS, the
likes of which graces my
Slimbook Pro2, and the new(er) Plasma 5.17 as seen on
KDE neon User Edition. The top image is from Kubuntu 18.04, and the bottom one is from neon. The Vault
icon is different, but the spacing is also different. More condensed. Not quite the way I like it.

Plasma 5.12, icon spacing

Plasma 5.17, icon spacing

Solution

So what we want is to increase the spacing between system area icons. I couldn’t find an obvious
option to change this through system settings. Indeed, we need to go obscure, and this mean making a
change in the QML-format configuration file for the relevant plasmoid. Some command-line hackery.

The system tray layout is controlled by the following file:

/usr/share/plasma/plasmoids/org.kde.plasma.private.systemtray/

contents/ui/main.qml

Now, this file will get overwritten every time there’s a Plasma update, so what we need is to copy
it into our home directory, and make a separate configuration there. This way, when the desktop loads,
your user overrides will be read and used on top of the system defaults. Exactly what we need.

Copy the entire plasmoid (systemtray):

cp -r /usr/share/plasma/plasmoids/org.kde.plasma.private.systemtray
~/.local/share/plasma/plasmoids

Then, in your home directory, navigate to:

~/.local/share/plasma/plasmoids/org.kde.plasma.private.systemtray/

contents/ui/main.qml

Open this file in a text editor. Now, search for the following string:

spacing: 0

This is the spacing defined between icons, by default. Since you may find the config file
intimidating, this the entire section where you will find this parameter declared and defined:

//Main Layout

Flow {

id: tasksRow

spacing: 0

height: parent.height – (vertical && expander.visible ?

expander.height : 0)

width: parent.width – (vertical || !expander.visible ? 0 :

expander.width)

property string skipItems

flow: vertical ? Flow.LeftToRight : Flow.TopToBottom

//To make it look centered

y: Math.round(height/2 – childrenRect.height/2)

x: (expander.visible && LayoutMirroring.enabled ? expander.width : 0)

+ Math.round(width/2 – childrenRect.width/2)

The solution is to change the spacing, to something like 3, 5 or whatever amount of pixels you want,
e.g.:

spacing: 10

Restart Plasma Shell

Save the file and restart your Plasma Shell. You can do this by launching
Krunner, and then running
the following command:

killall plasmashell && kstart plasmashell

Wait a second or two for the desktop to reload. Lo and behold, the system area icon spacing has
been fixed now, and it looks glorious and majestic, and exactly what you need to put the OCD demons to
rest. Here’s an example with 4px as the spacing value:

Icon spacing fixed

And we’re done, fellas!

Conclusion

Small aesthetic niggles can be quite annoying. And sometimes, you just can’t really ignore them.
Well, this is one of those, and I must say, with even just a few small pixels of padding added there,
things look so much better and more professional. The only downside is that one must dig deep into
nerdy stuff to get this configuration changed.

As you can see, it’s doable – and, you’ve also discovered a Pandora’s box of goodies. You can now
manually tweak plasmoids as you see them fit, and as you slowly become more accustomed to the QML code,
you can really change and edit the look & feel of the Plasma desktop. Best of all, if you garble
something BAR-like, you can simply delete your custom configuration from your home directory, and no
harm done. I hope you like and appreciate this tutorial. See you out there, Plasmateers.

Source