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