From 46f70f3836ec494979c024e9ff4ec544643c0a9e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 14 Nov 2025 15:38:16 +0100 Subject: ... --- .../shell/quickshell/Services/Worktime.qml | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 accounts/gkleen@sif/shell/quickshell/Services/Worktime.qml (limited to 'accounts/gkleen@sif/shell/quickshell/Services') diff --git a/accounts/gkleen@sif/shell/quickshell/Services/Worktime.qml b/accounts/gkleen@sif/shell/quickshell/Services/Worktime.qml new file mode 100644 index 00000000..fdb45aa0 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/Worktime.qml @@ -0,0 +1,75 @@ +pragma Singleton + +import QtQuick +import Quickshell +import Quickshell.Io +import QtQml + +Singleton { + id: root + + property alias time: timeState + property alias today: todayState + + CommandState { + id: timeState + command: "time" + } + CommandState { + id: todayState + command: "today" + } + + component CommandState : Scope { + id: commandState + + required property string command + property var state: null + + property bool strikeout: !strikeoutTimer.running + property alias running: process.running + property alias updating: updateTimer.running + + Process { + id: process + running: true + command: [ @worktime@, commandState.command, "--waybar" ] + stdout: StdioCollector { + id: processCollector + onStreamFinished: { + try { + commandState.state = JSON.parse(processCollector.text); + strikeoutTimer.restart(); + } catch (e) { + console.warn("Worktime: Failed to parse output:", processCollector.text, e); + } + } + } + } + + Timer { + id: updateTimer + running: commandState.state?.class == "running" || commandState.state?.class == "over" + interval: 60000 + repeat: true + onTriggered: process.running = true + } + + Timer { + id: strikeoutTimer + running: false + interval: 5 * updateTimer.interval + repeat: false + } + } + + Timer { + running: Boolean(timeState.state) && Boolean(todayState.state) && timeState.strikeout && todayState.strikeout + interval: 1000 + repeat: false + onTriggered: { + timeState.state = null; + todayState.state = null; + } + } +} -- cgit v1.2.3