aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/deckit/DeckIt.qml
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-18 16:56:01 +0100
committerDanilo M. <danix@danix.xyz>2026-11-18 16:56:01 +0100
commit44f947c642fe842fae80c7407399265aa47e9909 (patch)
treefba51fa5ddbfb9033a63aa1fda9b720f262848af /desktop/modules/deckit/DeckIt.qml
parent403d88813622c45ea270d5168e9875e582bad4d4 (diff)
downloadquickshell-44f947c642fe842fae80c7407399265aa47e9909.tar.gz
quickshell-44f947c642fe842fae80c7407399265aa47e9909.zip
feat(deckit): Start, Stop and Restart in the drawer
Running deck-it is a runtime operation, so it moves out of the settings window into a drawer tile: the deck-it page shows its status line and Start, Stop and Restart. The Server settings page keeps only the status line in its header. DeckIt.control(op) replaces restart(): the buttons stay disabled until deck-it status shows the result (running or waiting after a start, stopped after a stop) or 30s pass. A Restart waits 2s before believing the status, so the old instance's last answer does not count. The snackbar went with it: the drawer has none, and its page shows the status line instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/deckit/DeckIt.qml')
-rw-r--r--desktop/modules/deckit/DeckIt.qml43
1 files changed, 24 insertions, 19 deletions
diff --git a/desktop/modules/deckit/DeckIt.qml b/desktop/modules/deckit/DeckIt.qml
index 632285f..f39ad8c 100644
--- a/desktop/modules/deckit/DeckIt.qml
+++ b/desktop/modules/deckit/DeckIt.qml
@@ -58,9 +58,12 @@ Singleton {
// waiting, tablet, extend}; null until the first answer.
property var status: null
property int watchers: 0
- // A pending Restart, 0 when none; its outcome goes to the window's snackbar.
- property real restartAt: 0
- readonly property int restartTimeout: 30000
+ // A Start, Stop or Restart from the drawer while it takes effect, "" when
+ // none. It clears once `deck-it status` shows the result, or after busyTimeout.
+ property string busy: ""
+ property real busyAt: 0
+ readonly property int busyTimeout: 30000
+ readonly property bool running: !!root.status && (root.status.server || root.status.waiting)
// One line for the page.
readonly property string summary: {
@@ -75,24 +78,26 @@ Singleton {
readonly property bool healthy: !!root.status && root.status.server && root.status.tablet !== ""
&& (!root.status.extend || root.status.display)
- // Stops it and starts it again the way login does, so a saved config applies.
- function restart() {
- Quickshell.execDetached(["sh", "-c", "deck-it stop; exec deck-it wifi --wait"]);
- Snack.wait("Restarting deck-it…");
- root.restartAt = Date.now();
- // Let stop run first, or the first poll still sees the old instance.
+ // Start and Restart start it the way login does, so a saved config applies.
+ readonly property var commands: ({
+ start: "exec deck-it wifi --wait",
+ stop: "deck-it stop",
+ restart: "deck-it stop; exec deck-it wifi --wait"
+ })
+
+ function control(op) {
+ Quickshell.execDetached(["sh", "-c", root.commands[op]]);
+ root.busy = op;
+ root.busyAt = Date.now();
poll.restart();
}
- function checkRestart() {
- if (root.restartAt === 0) return;
- if (root.healthy) {
- Snack.ok("deck-it restarted");
- root.restartAt = 0;
- } else if (Date.now() - root.restartAt > root.restartTimeout) {
- Snack.error("deck-it not back after " + root.restartTimeout / 1000 + "s: " + root.summary);
- root.restartAt = 0;
- }
+ function checkBusy() {
+ if (!root.busy) return;
+ const age = Date.now() - root.busyAt;
+ // ponytail: 2s before believing a Restart, so the old instance's last answer does not count.
+ const done = root.busy === "stop" ? !!root.status && !root.running : root.running && age > 2000;
+ if (done || age > root.busyTimeout) root.busy = "";
}
Timer {
@@ -109,7 +114,7 @@ Singleton {
stdout: StdioCollector { id: statOut }
onExited: {
try { root.status = JSON.parse(statOut.text); } catch (e) { root.status = null; }
- root.checkRestart();
+ root.checkBusy();
}
}