Custom date configuration in KDE Plasma Digital Clocks

The new Digital Clock widget in KDE5 is nice, but lacks certain valuable configuration options. Notably:

  • You can only choose between three fixed date formats (short, long and ISO). Short and ISO formats do not include weekdays, so they are not very useful. Long format includes everything, but takes too much space since both the weekday and month are spelled in full. A much more preferred would be format like “Wed, Aug 9”
  • There is no way to make the date font smaller than time font through settings

However both of those options could be still customized.

Customizing the date format

To customize the date format, edit the plasmoid source code:

vi /usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/DigitalClock.qml

and find the following line:

dateLabel.text = Qt.formatDate(main.currentTime, main.dateFormat);

Replace it by the following:

dateLabel.text = Qt.formatDate(main.currentTime, "ddd, MMM d" );

this will give you the short weekday, short month name and day. You can customize it whatever way you want using the codes described here: – for example, to add a short year you can add “yy” in the string.

This customizes the date format in the vertical layout. To customize the date format in the left-to-right layout (date next to time) edit the following line:

dateLabelLeft.text = Qt.formatDate(main.currentTime, main.dateFormat);

Save the file, and restart plasma shell via:

killall plasmashell; kstart plasmashell

Customizing the date font size

To make the date font smaller, open the same file and search for the “id: dateLabel” string . Under it after a few lines you will see the following line:

font.pointSize: 1024

replace 1024 by a desired font size, such as 8. Save the file, and restart Plasma as above.

This entry was posted in Uncategorized.

4 Responses to Custom date configuration in KDE Plasma Digital Clocks

  1. Rob says:

    Thanks for the great update for something that shouldn’t have gone away in the first place.
    How about we change the color?
    I like lime green over the black sys tray, for one.


  2. Rala Cehiv says:

    Thanks for the helpful post. I wanted something a big different, formatted like 8/9/2018 for Aug 9 2018. The string was

    dateLabel.text = Qt.formatDate(main.currentTime, “M/d/yyyy”);

    Also, if you’re using Arch then you have to add a 5 to kstart when restarting the shell:

    killall plasmashell; kstart5 plasmashell

  3. Cat22 says:

    This is great except that font.pointSize doesn’t exist in my copy of:
    I’m using KDE 5.50.0 Plasma on opeSuse Tumbleweed (Leap 15)

    So I went onto a system with Leap 42,3 and the same file has that in it but its in numerous places, mostly in “PropertyChanges” stucts, which one should be changed to set the date to a smaller font?
    Also why is it set by default to 1024? That point size is gigantic.

    Well, i added font.pointSize: 8 to 2 PropertyChanges structs => target: dateLabel and target: timeLabel
    It seems to work to a degree, the time is still a bit large but my date string looks pretty good. further inspection shows there is another PropertyChanges struct called timeLabel and i commented out this line:

    font.pixelSize: Math.min(timeLabel.height, 3 * theme.defaultFont.pixelSize)

    which didn’t help at all

    Also the formats listed in the link you posted don’t work. e.g mmm only produces mmm when displayed
    instead of the abbreviated month name. You need to use the Qt date/time formats as sown here:

    So, I decided to try eventCalendar – that one is the ticket! Works great!

  4. Robert says:

    Wow, finally a solution to this messed up date-format implementation. I can’t believe it’s not customizable by default. Now it has just the info that one needs: “Sat Jul 27”

Leave a Reply

Your email address will not be published. Required fields are marked *

Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /home/ulduzs/public_html/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048