From ad1ee4cfc45a8f4e65ff68794ee5ab429f15ba79 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Wed, 18 Nov 2026 09:57:34 -0500 Subject: [PATCH] fix times getting stuck after suspend --- src/Bar.qml | 7 +------ src/LockSurface.qml | 9 ++------- src/Time.qml | 21 +++++++++++++++++++++ src/qmldir | 1 + 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 src/Time.qml diff --git a/src/Bar.qml b/src/Bar.qml index 078331c..e59a1c2 100644 --- a/src/Bar.qml +++ b/src/Bar.qml @@ -5,18 +5,13 @@ import Quickshell Rectangle { color: "black" - SystemClock { - id: clock - precision: SystemClock.Minutes - } - Text { anchors { left: parent.left leftMargin: 16 verticalCenter: parent.verticalCenter } - text: Qt.formatDateTime(clock.date, "HH:mm") + text: Qt.formatDateTime(Time.date, "HH:mm") color: Theme.text font.family: Theme.font font.pixelSize: 13 diff --git a/src/LockSurface.qml b/src/LockSurface.qml index 7e8e6f3..38f4873 100644 --- a/src/LockSurface.qml +++ b/src/LockSurface.qml @@ -38,11 +38,6 @@ WlSessionLockSurface { brightness: -0.05 } - SystemClock { - id: clock - precision: SystemClock.Minutes - } - Connections { target: surface.lock @@ -77,7 +72,7 @@ WlSessionLockSurface { Text { Layout.alignment: Qt.AlignHCenter - text: Qt.formatTime(clock.date, "HH:mm") + text: Qt.formatTime(Time.date, "HH:mm") color: Theme.text font.family: Theme.font font.pixelSize: 88 @@ -86,7 +81,7 @@ WlSessionLockSurface { Text { Layout.alignment: Qt.AlignHCenter - text: Qt.formatDate(clock.date, "dddd, MMMM d") + text: Qt.formatDate(Time.date, "dddd, MMMM d") color: Theme.subtext font.family: Theme.font font.pixelSize: 18 diff --git a/src/Time.qml b/src/Time.qml new file mode 100644 index 0000000..b3b9487 --- /dev/null +++ b/src/Time.qml @@ -0,0 +1,21 @@ +pragma Singleton + +import QtQuick +import Quickshell + +Singleton { + id: root + + property date date: new Date() + + Timer { + interval: 1000 + running: true + repeat: true + onTriggered: { + const now = new Date(); + if (now.getMinutes() !== root.date.getMinutes() || now.getHours() !== root.date.getHours() || now.getDate() !== root.date.getDate()) + root.date = now; + } + } +} diff --git a/src/qmldir b/src/qmldir index b7320d1..11007c9 100644 --- a/src/qmldir +++ b/src/qmldir @@ -1,6 +1,7 @@ singleton Notifications Notifications.qml singleton Status Status.qml singleton Theme Theme.qml +singleton Time Time.qml Bar Bar.qml Lock Lock.qml LockSurface LockSurface.qml