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.

Leave a Reply

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