fix times getting stuck after suspend

This commit is contained in:
Henry Hiles 2026-11-18 09:57:34 -05:00
commit ad1ee4cfc4
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
4 changed files with 25 additions and 13 deletions

View file

@ -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

View file

@ -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

21
src/Time.qml Normal file
View file

@ -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;
}
}
}

View file

@ -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