aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/deckit
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
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')
-rw-r--r--desktop/modules/deckit/DeckIt.qml43
-rw-r--r--desktop/modules/deckit/DeckItControlModule.qml63
-rw-r--r--desktop/modules/deckit/DeckItGeneralPage.qml2
-rw-r--r--desktop/modules/deckit/DeckItModule.qml7
-rw-r--r--desktop/modules/deckit/README.md28
5 files changed, 103 insertions, 40 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();
}
}
diff --git a/desktop/modules/deckit/DeckItControlModule.qml b/desktop/modules/deckit/DeckItControlModule.qml
new file mode 100644
index 0000000..311de1c
--- /dev/null
+++ b/desktop/modules/deckit/DeckItControlModule.qml
@@ -0,0 +1,63 @@
+// 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 "../.."
+
+// deck-it's runtime controls in the drawer: its state, Start, Stop and
+// Restart. Its settings stay in the settings window's deck-it pages.
+Module {
+ name: "deckit-run"
+ label: "deck-it"
+ // nf-md-tablet, as on the Server page.
+ icon: "󰓶"
+
+ page: Component {
+ Page {
+ title: "deck-it"
+ Column {
+ width: parent.width
+ spacing: 12
+ // `deck-it status` polls only while this page is open.
+ Component.onCompleted: DeckIt.watchers++
+ Component.onDestruction: DeckIt.watchers--
+
+ Text {
+ width: parent.width
+ wrapMode: Text.Wrap
+ text: ({ start: "Starting…", stop: "Stopping…", restart: "Restarting…" })[DeckIt.busy]
+ ?? DeckIt.summary
+ color: DeckIt.healthy ? Theme.green : DeckIt.running ? Theme.yellow : Theme.red
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize }
+ }
+ Row {
+ spacing: 8
+ Button {
+ text: "Start"
+ enabled: !DeckIt.busy && !!DeckIt.status && !DeckIt.running
+ onClicked: DeckIt.control("start")
+ }
+ Button {
+ text: "Stop"
+ enabled: !DeckIt.busy && DeckIt.running
+ onClicked: DeckIt.control("stop")
+ }
+ Button {
+ text: "Restart"
+ enabled: !DeckIt.busy && DeckIt.running
+ onClicked: DeckIt.control("restart")
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/desktop/modules/deckit/DeckItGeneralPage.qml b/desktop/modules/deckit/DeckItGeneralPage.qml
index 776099a..7bcfe71 100644
--- a/desktop/modules/deckit/DeckItGeneralPage.qml
+++ b/desktop/modules/deckit/DeckItGeneralPage.qml
@@ -25,7 +25,7 @@ Column {
readonly property var st: DeckIt.store
function def(section, key) { return col.st.fallback(section, key); }
- Small { text: DeckIt.path + ", only the keys that differ from deck-it's defaults. Saved changes apply when deck-it restarts." }
+ Small { text: DeckIt.path + ", only the keys that differ from deck-it's defaults. Saved changes apply when deck-it restarts (the drawer's deck-it tile)." }
Small { visible: DeckIt.defaultsError !== ""; color: Theme.red; text: DeckIt.defaultsError }
Component.onCompleted: DeckIt.watchers++
Component.onDestruction: DeckIt.watchers--
diff --git a/desktop/modules/deckit/DeckItModule.qml b/desktop/modules/deckit/DeckItModule.qml
index f3986e9..a47e7da 100644
--- a/desktop/modules/deckit/DeckItModule.qml
+++ b/desktop/modules/deckit/DeckItModule.qml
@@ -15,7 +15,7 @@ import "../.."
import "../qtmaildir"
// deck-it, the tablet dashboard: Server, the first of its four pages, with
-// its state and Restart in the header. See README.md.
+// its state in the header; Start, Stop and Restart are the drawer's deck-it tile. See README.md.
Module {
id: mod
name: "deckit"
@@ -57,11 +57,6 @@ Module {
: Theme.red
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
}
- Button {
- text: DeckIt.restartAt ? "Restarting…" : "Restart"
- enabled: !DeckIt.restartAt
- onClicked: DeckIt.restart()
- }
SaveBar {
dirty: DeckIt.store.dirty; valid: DeckIt.store.valid; error: DeckIt.store.error
onSave: DeckIt.save(); onDiscard: DeckIt.store.discard()
diff --git a/desktop/modules/deckit/README.md b/desktop/modules/deckit/README.md
index 197b382..b3bd39b 100644
--- a/desktop/modules/deckit/README.md
+++ b/desktop/modules/deckit/README.md
@@ -2,12 +2,12 @@
Four settings pages, in their own deck-it sidebar group, for deck-it (the
tablet dashboard, its own repo): whether it starts at login, and its
-`~/.config/deck-it/config.toml`.
+`~/.config/deck-it/config.toml`. Running it is the drawer's: a deck-it tile
+(`DeckItControlModule`) with its state, Start, Stop and Restart.
- Server (`DeckItModule`, `DeckItGeneralPage`): the config path, Start
(start at login, Wi-Fi address), Display, Tabs (the tablet's tabs) and
- Advanced (ports, Hyprland config, fallback icon theme). Its header carries deck-it's state and
- Restart.
+ Advanced (ports, Hyprland config, fallback icon theme). Its header carries deck-it's state.
- Dashboard (`DeckItDashboardModule`, `DeckItDashboardPage`): the
Dashboard parts (the modules without a tab), the action icons, the
tablet screen's idle dimming, and Hardware. `Modules.js` says which of deck-it's `[modules]` are tabs and
@@ -42,17 +42,17 @@ Launchers are desktop ids (`[launch] apps`), added from the installed apps
the way the Autostart page picks one, minus terminal apps. Up and Remove edit
the list; the order is the button order on the tablet.
-deck-it reads its config once at start, so a save applies on Restart
-deck-it, which runs `deck-it stop` and then the login command.
-
-While the Server page is open it polls `deck-it status` (JSON: server, display,
-waiting, tablet, extend) every 2s and shows one line in that page's header,
-beside Restart and Save, as the Wallpaper engine page does: green when the
-server runs with a tablet tunnelled (and the display streams, if enabled),
-yellow while starting or waiting for the tablet, red when stopped. A Restart's
-outcome goes to the window's snackbar: "deck-it restarted" once that state is
-green, or what it saw if it is not back within 30s; a `wifi --wait` with no
-tablet in reach ends there.
+deck-it reads its config once at start, so a save applies on the drawer
+tile's Restart, which runs `deck-it stop` and then the login command; Start
+runs the login command, Stop `deck-it stop`.
+
+While the Server page or the drawer's deck-it page is open it polls `deck-it
+status` (JSON: server, display, waiting, tablet, extend) every 2s and shows
+one line: green when the server runs with a tablet tunnelled (and the display
+streams, if enabled), yellow while starting or waiting for the tablet, red
+when stopped. A Start, Stop or Restart shows "Starting…" and so on, and
+disables the buttons, until the status shows it done (running or waiting, or
+stopped) or 30s pass.
Check: `node desktop/modules/sbbuilder/test_toml.js`; the deck-it side is
tested in its repo.