This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Wrong time format in plasma5 lock screen

Tags: None
(comma "," separated)
H.Merijn
Registered Member
Posts
1
Karma
0
I am using OpenSUSE-Tumbleweed with KDE/Plasma5

Linux 4.3.3-5-default [openSUSE Tumbleweed (20151124) (x86_64)] HP EliteBook 8560p/1618 Core(TM) i7-2620M CPU @ 2.70GHz/1906(4) x86_64 7932 Mb

kscreenlocker-5.5.2-1.1.x86_64
kscreenlocker-lang-5.5.2-1.1.noarch
kwin-4.11.22-4.1.x86_64
plasma5-desktop-5.5.2-2.1.x86_64
plasma5-session-5.5.2-1.1.noarch
plasma5-workspace-5.5.2-1.1.x86_64

I have globally "fixed" the date, time, address, measurements, monetary, and paper formats to sensible display (for my region). I altered them as I want the other stuff to be English/UTF-8. This works great in most if not close to all other applications, but not in the plasma5 lock screen where the time is still shown in the H:MM AP/PM notation, which is not what I want (I want %R instead of %r).

1. %m/%d/%y → %d-%m-%y
2. %a %b %e %H:%M:%S %Z %Y → %a %e %b %Y %H:%M:%S
3. %I:%M:%S %p → %H:%M:%S
4. %r → %R
5. Letter → A4

Code: Select all
$ locale -ck LC_TIME
LC_TIME
abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat"
day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday"
abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
mon="January;February;March;April;May;June;July;August;September;October;November;December"
am_pm="AM;PM"
d_t_fmt="%a %d %b %Y %R %Z"
d_fmt="%d-%m-%Y"
t_fmt="%R"
t_fmt_ampm="%H:%M:%S"
era=
era_year=""
era_d_fmt=""
alt_digits=
era_d_t_fmt=""
era_t_fmt=""
time-era-num-entries=0
time-era-entries="S"
week-ndays=7
week-1stday=19971130
week-1stweek=7
first_weekday=1
first_workday=2
cal_direction=1
timezone=""
date_fmt="%a %e %b %Y %H:%M:%S"
time-codeset="UTF-8"


I dug and dug, but found no option or location where I could change the (imho stupid) %r (AM/PM) notation to %R (24-hour) notation

Another minor annoyance is that when I change Workspace Theme > Desktop Theme in systemsettings5 from openSUSE to Breeze, it is somehow not saved and the next desktop starts in openSUSE again.
User avatar
Rog131
Registered Member
Posts
828
Karma
10
If there is no other solution then you could edit the qml scripts.

The lock screen is part of the look-and-feel: /usr/share/plasma/look-and-feel/. The Breeze date and time format can be edited from the /usr/share/plasma/look-and-feel/org.kde.breeze.desktop/contents/components/InfoPane.qml

Image


An example

Changing the Time/date from:

Image

To

Image

The InfoPane.qml at here:

Code: Select all
/*
 *   Copyright 2014 David Edmundson <davidedmundson@kde.org>
 *   Copyright (C) 2014 by Aleix Pol Gonzalez <aleixpol@blue-systems.com>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import QtQuick 2.2
import QtQuick.Layouts 1.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.workspace.components 2.0 as PW

ColumnLayout {
   BreezeLabel { //should be a heading but we want it _loads_ bigger
        //text: Qt.formatTime(timeSource.data["Local"]["DateTime"])
        text: Qt.formatTime(timeSource.data["Local"]["DateTime"], "hh:mm:ss")
        //we fill the width then align the text so that we can make the text shrink to fit
        Layout.fillWidth: true
        horizontalAlignment: Text.AlignRight

        font.weight: Font.DemiBold
        fontSizeMode: Text.HorizontalFit
        font.pointSize: 36
    }

    BreezeLabel {
        //text: Qt.formatDate(timeSource.data["Local"]["DateTime"], Qt.DefaultLocaleLongDate);
        text: Qt.formatDate(timeSource.data["Local"]["DateTime"], "yyyy/MM/dd");
        Layout.alignment: Qt.AlignRight
        font.weight: Font.DemiBold
        fontSizeMode: Text.HorizontalFit
        font.pointSize: 26
    }

    RowLayout {
        Layout.alignment: Qt.AlignRight
        visible: pmSource.data["Battery"]["Has Cumulative"]

        PW.BatteryIcon {
            id: battery
            hasBattery: true
            percent: pmSource.data["Battery"]["Percent"]
            pluggedIn: pmSource.data["AC Adapter"] ? pmSource.data["AC Adapter"]["Plugged in"] : false

            height: batteryLabel.height
            width: batteryLabel.height
        }

        BreezeLabel {
            id: batteryLabel
            text: {
                var state = pmSource.data["Battery"] ? pmSource.data["Battery"]["State"] : "";
                switch(state) {
                case "Charging":
                    return i18nd("plasma_lookandfeel_org.kde.lookandfeel","%1%. Charging", battery.percent)
                case "FullyCharged":
                    return i18nd("plasma_lookandfeel_org.kde.lookandfeel","Fully charged")
                default:
                    return i18nd("plasma_lookandfeel_org.kde.lookandfeel","%1% battery remaining", battery.percent)
                }
            }
            Layout.alignment: Qt.AlignRight
            wrapMode: Text.Wrap
        }
    }

   
    PlasmaCore.DataSource {
        id: pmSource
        engine: "powermanagement"
        connectedSources: ["Battery", "AC Adapter"]
    }

    PlasmaCore.DataSource {
        id: timeSource
        engine: "time"
        connectedSources: ["Local"]
        interval: 1000
    }

}



Qt Qml time format: http://doc.qt.io/qt-5/qml-qtqml-qt.html ... formatters

Not editing the Breeze look and feel theme but copying the theme under another name and editing it: https://www.kubuntuforums.net/showthrea ... post382461

Image
IMayNeed
Registered Member
Posts
3
Karma
0
OS
This applies to lock screen, but not to the login screen when you start the computer.
How can you make it so that it applies to the login screen when you start the computer?
Thanks:
User avatar
Rog131
Registered Member
Posts
828
Karma
10
IMayNeed wrote:This applies to lock screen, but not to the login screen when you start the computer.
How can you make it so that it applies to the login screen when you start the computer?
Thanks:


It depends

The time format of the login screen depends your:

- login/display manager. KDE default is the SDDM: https://en.wikipedia.org/wiki/Simple_De ... ay_Manager
- login manager theme. KDE default is the Breeze.
- system locales: https://en.wikipedia.org/wiki/Locale_(computer_software)

Your distribution could have a doc page: How to set/change the system locales.
With the Arch Linux (used at here) : https://wiki.archlinux.org/index.php/locale


Changing KDE Breeze SDDM theme time format

Plasma 5.8

Plasma 5.8 Breeze SDDM theme time format is set at /usr/share/sddm/themes/breeze/components/Clock.qml

Image

Changing time format from

Image

to

Image

with

.../breeze/components/Clock.qml:

Code: Select all
/*
 *   Copyright 2016 David Edmundson <davidedmundson@kde.org>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import QtQuick 2.0
import QtQuick.Layouts 1.1

import org.kde.plasma.core 2.0
import org.kde.plasma.components 2.0

ColumnLayout {
    Label {
        //text: Qt.formatTime(timeSource.data["Local"]["DateTime"])
        text: Qt.formatTime(timeSource.data["Local"]["DateTime"], "hh:mm:ss")
        font.pointSize: 32 //Mockup says this, I'm not sure what to do?
        Layout.alignment: Qt.AlignHCenter
    }
    Label {
        //text: Qt.formatDate(timeSource.data["Local"]["DateTime"], Qt.DefaultLocaleLongDate)
        text: Qt.formatDate(timeSource.data["Local"]["DateTime"], "yyyy/MM/dd")
        font.pointSize: 18
        Layout.alignment: Qt.AlignHCenter
    }
    DataSource {
        id: timeSource
        engine: "time"
        connectedSources: ["Local"]
        interval: 1000
    }
}


Note #1

Upgrades will overwrite the changes to the Breeze SDDM theme. A better way is copy the Breeze theme under another name - an example: viewtopic.php?f=289&t=131783#p364567


Note #2

The Breeze theme is depending the plasma version - with the Plasma 5.7.5 the clock time is at .../breeze/components/InfoPane.qml


More

- SDDM: https://github.com/sddm/sddm -> Docs: https://github.com/sddm/sddm/tree/develop/docs
- Date QML Type: http://doc.qt.io/qt-5/qml-qtqml-date.html
IMayNeed
Registered Member
Posts
3
Karma
0
OS
Thank you so much for the information.

It is strange that the desktop clock shows 2:01:03 but the login screen and the lock screen shows 02:01:03 as I want.
Now, I have to figure out how to show it as 02:01:03 on the desktop.
Do you think you can help with that one?

Thanks again.
User avatar
Rog131
Registered Member
Posts
828
Karma
10
IMayNeed wrote:Thank you so much for the information.

It is strange that the desktop clock shows 2:01:03 but the login screen and the lock screen shows 02:01:03 as I want.
Now, I have to figure out how to show it as 02:01:03 on the desktop.
Do you think you can help with that one?

Thanks again.


You could edit the digital clock time format - an example - 'My Digital Clock': viewtopic.php?f=17&t=134970&p=361132#p361132
Image
IMayNeed
Registered Member
Posts
3
Karma
0
OS
Thanks again.

I don't have a plasma folder under /.local/share.
Can I paste the folder anywhere?

I will have to work on this in a few days.
I am dealing with cannot load kdesudo error at the moment.

Thank you very much for your help.
User avatar
Rog131
Registered Member
Posts
828
Karma
10
IMayNeed wrote:Thanks again.

I don't have a plasma folder under /.local/share.
Can I paste the folder anywhere?



The KDE is looking things along paths.

System: /usr/share/plasma/...
User: $HOME/.local/share/plasma/...

User home data paths: https://specifications.freedesktop.org/ ... atest.html

$XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.


Plasma is looking user bits and pieces from $HOME/.local/share/plasma/...

User can create and remove things to/from the $HOME as user wish.

Image


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]