aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules')
-rw-r--r--desktop/modules/deckit/DeckIt.qml14
-rw-r--r--desktop/modules/deckit/DeckItModule.qml27
-rw-r--r--desktop/modules/deckit/DeckItPage.qml27
-rw-r--r--desktop/modules/deckit/README.md12
4 files changed, 36 insertions, 44 deletions
diff --git a/desktop/modules/deckit/DeckIt.qml b/desktop/modules/deckit/DeckIt.qml
index 8d24917..632285f 100644
--- a/desktop/modules/deckit/DeckIt.qml
+++ b/desktop/modules/deckit/DeckIt.qml
@@ -14,6 +14,7 @@ pragma Singleton
import Quickshell
import Quickshell.Io
import QtQuick
+import "../.."
import "../sbbuilder"
import "../autostart/Autostart.js" as A
@@ -57,9 +58,7 @@ Singleton {
// waiting, tablet, extend}; null until the first answer.
property var status: null
property int watchers: 0
- // The last Restart's outcome; restartAt is 0 when none is pending.
- property string note: ""
- property bool noteBad: false
+ // A pending Restart, 0 when none; its outcome goes to the window's snackbar.
property real restartAt: 0
readonly property int restartTimeout: 30000
@@ -79,8 +78,7 @@ Singleton {
// 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"]);
- root.note = "Restarting…";
- root.noteBad = false;
+ Snack.wait("Restarting deck-it…");
root.restartAt = Date.now();
// Let stop run first, or the first poll still sees the old instance.
poll.restart();
@@ -89,12 +87,10 @@ Singleton {
function checkRestart() {
if (root.restartAt === 0) return;
if (root.healthy) {
- root.note = "Restarted at " + Qt.formatTime(new Date(), "HH:mm:ss");
- root.noteBad = false;
+ Snack.ok("deck-it restarted");
root.restartAt = 0;
} else if (Date.now() - root.restartAt > root.restartTimeout) {
- root.note = "Not back after " + root.restartTimeout / 1000 + "s: " + root.summary;
- root.noteBad = true;
+ Snack.error("deck-it not back after " + root.restartTimeout / 1000 + "s: " + root.summary);
root.restartAt = 0;
}
}
diff --git a/desktop/modules/deckit/DeckItModule.qml b/desktop/modules/deckit/DeckItModule.qml
index 2e46302..fbf6bd0 100644
--- a/desktop/modules/deckit/DeckItModule.qml
+++ b/desktop/modules/deckit/DeckItModule.qml
@@ -45,10 +45,31 @@ Module {
page: Component {
Page {
title: "deck-it"
+ // Its state in the header, as the Wallpaper engine page does:
+ // `deck-it status`, polled while the page is open (DeckIt.watchers).
actions: Component {
- SaveBar {
- dirty: DeckIt.store.dirty; valid: DeckIt.store.valid; error: DeckIt.store.error
- onSave: DeckIt.save(); onDiscard: DeckIt.store.discard()
+ Row {
+ spacing: 8
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ // ponytail: a long summary elides; the header has one line.
+ width: Math.min(implicitWidth, 420)
+ elide: Text.ElideRight
+ text: DeckIt.summary
+ color: DeckIt.healthy ? Theme.green
+ : DeckIt.status && (DeckIt.status.server || DeckIt.status.waiting) ? Theme.yellow
+ : 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()
+ }
}
}
DeckItPage { width: parent.width }
diff --git a/desktop/modules/deckit/DeckItPage.qml b/desktop/modules/deckit/DeckItPage.qml
index 070b2be..fe4092c 100644
--- a/desktop/modules/deckit/DeckItPage.qml
+++ b/desktop/modules/deckit/DeckItPage.qml
@@ -50,33 +50,6 @@ Column {
Component.onCompleted: DeckIt.watchers++
Component.onDestruction: DeckIt.watchers--
- Item {
- width: col.width
- height: 34
- Rectangle {
- id: dot
- anchors { left: parent.left; verticalCenter: parent.verticalCenter }
- width: 10; height: 10; radius: 5
- color: DeckIt.healthy ? Theme.green : DeckIt.status && (DeckIt.status.server || DeckIt.status.waiting)
- ? Theme.yellow : Theme.red
- }
- Text {
- anchors { left: dot.right; leftMargin: 10; right: restartBtn.left; rightMargin: 8; verticalCenter: parent.verticalCenter }
- elide: Text.ElideRight
- text: DeckIt.summary
- color: Theme.text
- font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
- }
- Button {
- id: restartBtn
- anchors { right: parent.right; verticalCenter: parent.verticalCenter }
- text: DeckIt.restartAt ? "Restarting…" : "Restart deck-it"
- enabled: !DeckIt.restartAt
- onClicked: DeckIt.restart()
- }
- }
- Small { visible: DeckIt.note !== ""; color: DeckIt.noteBad ? Theme.red : Theme.green; text: DeckIt.note }
-
Heading { text: "Start" }
Item {
objectName: "autostart/"
diff --git a/desktop/modules/deckit/README.md b/desktop/modules/deckit/README.md
index 59c85fd..abfd7be 100644
--- a/desktop/modules/deckit/README.md
+++ b/desktop/modules/deckit/README.md
@@ -26,11 +26,13 @@ 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 page is open it polls `deck-it status` (JSON: server, display,
-waiting, tablet, extend) every 2s and shows one line with a dot: 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. After a
-Restart it reports "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.
+waiting, tablet, extend) every 2s and shows one line in the page 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.
Check: `node desktop/modules/sbbuilder/test_toml.js`; the deck-it side is
tested in its repo.