aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/status
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-18 17:24:50 +0200
committerDanilo M. <danix@danix.xyz>2026-09-18 17:24:50 +0200
commitfd2df91659d5156d6224e9b170dca3167603d18f (patch)
treeef2391875132e95706311e4251c9bfeb70e39524 /desktop/modules/status
parentf40f9b9fd1369f244c7a064a9ec083104f52a3f9 (diff)
downloadquickshell-fd2df91659d5156d6224e9b170dca3167603d18f.tar.gz
quickshell-fd2df91659d5156d6224e9b170dca3167603d18f.zip
feat(status): a breaktimer row in the status page
Into the status module rather than a module of its own: break state is one more thing the desktop is doing, which is what that page already is, and Status.qml was already where breaktimer.sh is called from. The paused state shows no number. The countdown is frozen while paused and a frozen number reads as a bug, so the row says what it is instead.
Diffstat (limited to 'desktop/modules/status')
-rw-r--r--desktop/modules/status/BreakRow.qml94
-rw-r--r--desktop/modules/status/StatusPage.qml10
2 files changed, 104 insertions, 0 deletions
diff --git a/desktop/modules/status/BreakRow.qml b/desktop/modules/status/BreakRow.qml
new file mode 100644
index 0000000..70ad3ea
--- /dev/null
+++ b/desktop/modules/status/BreakRow.qml
@@ -0,0 +1,94 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// 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.
+
+import QtQuick
+import "../.."
+
+// Breaktimer: the daemon's phase and countdown, a pause switch and a
+// start/stop button. Every control is a verb; nothing here writes the
+// daemon's files.
+Item {
+ id: row
+
+ implicitHeight: Math.max(texts.implicitHeight, controls.implicitHeight) + 16
+
+ readonly property string phaseLabel: {
+ if (!Status.btRunning) return "Stopped";
+ if (Status.btPaused) return "Paused";
+ if (Status.btPhase === "breaking") return "Micro-pause";
+ if (Status.btPhase === "longbreak") return "Long pause";
+ return "Working";
+ }
+
+ // A paused countdown is frozen, and a frozen number reads as a bug, so
+ // the paused state says what it is instead of showing one.
+ readonly property string detail: {
+ if (!Status.btRunning) return "Break reminders are not running.";
+ if (Status.btPaused) return "Countdown frozen until resumed.";
+ if (Status.btPhase === "breaking" || Status.btPhase === "longbreak")
+ return "Back to work in " + Status.btCountdown() + ".";
+ return "Next break in " + Status.btCountdown() + ".";
+ }
+
+ Column {
+ id: texts
+ anchors {
+ left: parent.left
+ right: controls.left
+ rightMargin: 12
+ verticalCenter: parent.verticalCenter
+ }
+ spacing: 2
+
+ Text {
+ text: "Breaktimer · " + row.phaseLabel
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true }
+ color: Theme.text
+ }
+
+ Text {
+ width: parent.width
+ wrapMode: Text.WordWrap
+ text: row.detail
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ color: Theme.subtext
+ }
+ }
+
+ Row {
+ id: controls
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ spacing: 8
+
+ Button {
+ text: Status.btRunning ? "Stop" : "Start"
+ danger: Status.btRunning
+ onClicked: Status.runBreaktimer(Status.btRunning ? "stop" : "start")
+ }
+
+ Switch {
+ id: sw
+ enabled: Status.btRunning
+ checked: Status.btRunning && !Status.btPaused
+ onToggled: Status.runBreaktimer(Status.btPaused ? "resume" : "pause")
+ }
+ }
+
+ // The shared Switch writes `checked` on click and so drops the binding
+ // above. Resync on any state change, which also covers a change made from
+ // the waybar module's own bindings or from a terminal.
+ Connections {
+ target: Status
+ function onBtStateChanged() {
+ sw.checked = Status.btRunning && !Status.btPaused;
+ }
+ }
+}
diff --git a/desktop/modules/status/StatusPage.qml b/desktop/modules/status/StatusPage.qml
index 470856d..7da7a0d 100644
--- a/desktop/modules/status/StatusPage.qml
+++ b/desktop/modules/status/StatusPage.qml
@@ -60,4 +60,14 @@ Column {
SnoozeRow {
width: page.width
}
+
+ Rectangle {
+ width: page.width
+ height: 1
+ color: Qt.alpha(Theme.text, 0.08)
+ }
+
+ BreakRow {
+ width: page.width
+ }
}