13 July 2011

Theming the clock in KDE.

The default digital clock plasmoid (that's KDE's fancy term for a desktop widget, by the way) in KDE 4 so far has not been particularly configurable. You can change the font it uses, but not the font size, nor specify in much detail how the date is displayed. For example, after a bit of fiddling around, I'd managed to make some progress, but it seems to "guess" a lot of things, and get them wrong sometimes. I got it looking like this:

KDE's default clock plasmoid, after a bit of tweaking.

It has clearly not guessed the right font sizes.

But, never fear, since there are a number of alternative clock plasmoids. One particularly configurable one is adjustable clock. For some reason, the built-in "get new plasmoids" thing couldn't find this for me, but there's an Archlinux PKGBUILD in the AUR.

On the face of it (no pun intended) this looks basically the same, but due to Plasma's great styling and scripting engines, you can specify any layout you like using HTML and CSS.

I wrote this snippet:

<div style="text-align:center; white-space: nowrap; opacity:0.85; background:none; padding: 12px 0 0px 0;">
    <span style="font-size: 52px; font-family:'Gill Sans MT Pro'; text-shadow: black 0.1em 0.1em 0.2em">
        <span style="color: rgb(255, 255, 255);"><b>%!t</b></span>
        <span style="color: rgb(200, 200, 200);"> %T</span>

This is fairly self-explanatory, I guess, but %!t provides the time sans seconds, while %T provides the long date. The full range of options are available from inside the adjustable clock's settings panel.

Here it is what it looks like:

KDE's adjustable clock plasmoid, with the above HTML.

Now, there's still a quite annoying algorithm for scaling the widget, meaning that it's the ratios between font sizes and padding etc., that you have to get right, but a bit of fiddling and it's okay.

Let's hope KDE continues to remain as configurable as it has been known for!

Categories: All articles KDE