diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-18 17:04:57 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-18 17:04:57 +0100 |
| commit | e55c1f32b383c53d12dc7c2b3c5e2e6ccb146cdc (patch) | |
| tree | fee3f3ced727f01c7bc630418a6e0b47d347df40 /desktop | |
| parent | 44f947c642fe842fae80c7407399265aa47e9909 (diff) | |
| download | quickshell-e55c1f32b383c53d12dc7c2b3c5e2e6ccb146cdc.tar.gz quickshell-e55c1f32b383c53d12dc7c2b3c5e2e6ccb146cdc.zip | |
feat(services): one drawer page to start, stop and restart services
Running things is a runtime operation, so it belongs in the drawer, not
the settings window. The drawer's deck-it tile and keystone's Shells page
become one Services tile: every quickshell shell, deck-it, and the
desktop's long-running daemons (desktop-assistant, cal-notif, tv-mpris,
mail-watcher, mail-notify, hypridle, hyprsunset, the polkit agent,
notifyd, playerctld, conky and cliphist's watcher), each with Start,
Stop and Restart.
A daemon's start command is its enabled autostart.lua line, run through
hyprctl dispatch hl.dsp.exec_cmd as Autostart's Try does, so conky keeps
its workspace rule and no command is copied out of autostart.lua.
Services.js holds only the label, the piece of the line that finds it
and the pgrep/pkill arguments. Stop waits up to 5s for the process to
exit, which hyprsunset needs to free Hyprland's CTM manager. -f patterns
bracket a letter so pgrep and pkill never match the sh that runs them.
Checked: test_services.js; the pgrep list reports all twelve daemons
running; a playerctld restart through the same command came back under
a new pid. QML's JS engine has no Array.flatMap, hence the concat.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/modules/deckit/DeckItControlModule.qml | 63 | ||||
| -rw-r--r-- | desktop/modules/deckit/DeckItGeneralPage.qml | 2 | ||||
| -rw-r--r-- | desktop/modules/deckit/DeckItModule.qml | 2 | ||||
| -rw-r--r-- | desktop/modules/deckit/README.md | 10 | ||||
| -rw-r--r-- | desktop/modules/services/README.md | 41 | ||||
| -rw-r--r-- | desktop/modules/services/Services.js | 43 | ||||
| -rw-r--r-- | desktop/modules/services/ServicesModule.qml | 135 | ||||
| -rw-r--r-- | desktop/modules/services/ServicesPage.qml | 92 | ||||
| -rwxr-xr-x | desktop/modules/services/restart.sh (renamed from desktop/modules/shells/restart.sh) | 0 | ||||
| -rw-r--r-- | desktop/modules/services/test_services.js | 46 | ||||
| -rw-r--r-- | desktop/modules/shells/README.md | 21 | ||||
| -rw-r--r-- | desktop/modules/shells/ShellsModule.qml | 80 | ||||
| -rw-r--r-- | desktop/modules/shells/ShellsPage.qml | 51 | ||||
| -rw-r--r-- | desktop/shell.qml | 5 |
14 files changed, 366 insertions, 225 deletions
diff --git a/desktop/modules/deckit/DeckItControlModule.qml b/desktop/modules/deckit/DeckItControlModule.qml deleted file mode 100644 index 311de1c..0000000 --- a/desktop/modules/deckit/DeckItControlModule.qml +++ /dev/null @@ -1,63 +0,0 @@ -// 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 7bcfe71..934912a 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 (the drawer's deck-it tile)." } + Small { text: DeckIt.path + ", only the keys that differ from deck-it's defaults. Saved changes apply when deck-it restarts (the drawer's Services)." } 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 a47e7da..1a20170 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 in the header; Start, Stop and Restart are the drawer's deck-it tile. See README.md. +// its state in the header; Start, Stop and Restart are in the drawer's Services. See README.md. Module { id: mod name: "deckit" diff --git a/desktop/modules/deckit/README.md b/desktop/modules/deckit/README.md index b3bd39b..59e5d4e 100644 --- a/desktop/modules/deckit/README.md +++ b/desktop/modules/deckit/README.md @@ -2,8 +2,8 @@ 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`. Running it is the drawer's: a deck-it tile -(`DeckItControlModule`) with its state, Start, Stop and Restart. +`~/.config/deck-it/config.toml`. Running it is the drawer's: its row on the +Services page (`modules/services`) has 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 @@ -42,11 +42,11 @@ 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 the drawer -tile's Restart, which runs `deck-it stop` and then the login command; Start +deck-it reads its config once at start, so a save applies on the +Services row'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 +While the Server page or the drawer's Services 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 diff --git a/desktop/modules/services/README.md b/desktop/modules/services/README.md new file mode 100644 index 0000000..982a6b8 --- /dev/null +++ b/desktop/modules/services/README.md @@ -0,0 +1,41 @@ +# services + +The drawer's Services tile: every quickshell shell, deck-it and the desktop's +daemons, one row each, with Start when stopped and Stop and Restart when +running. Their state is read every 2s while the page is open. Runtime only: +what starts at login is the settings window's Autostart page, deck-it's +settings are its four pages there. + +Shells are the directories in the repo holding a `shell.qml`, running when +`qs list --all` shows an instance on one. Start, Restart and Restart all run +`reload.sh`, wrapped by `restart.sh`, which then sends one notification +naming the shells that came back, or a critical one naming those that did +not. Back means a `qs` instance on the shell's config path under a pid it did +not have before, within 5s: the old instance can linger in the list for a +moment after `qs kill`. It is the process, not the config: a shell that starts +with a broken component counts as back. Stop is `qs kill -p <dir>`. The +desktop row has no Stop, since that shell draws the drawer; its Restart works +because every action is started with `Quickshell.execDetached`, outside the +desktop shell's process, so the script carries on and starts the new one. A +hung desktop shell cannot be restarted from here; `./reload.sh` from a +terminal remains the way out. + +deck-it's row goes through `DeckIt.control()` (`modules/deckit`): Start runs +the login command, Stop `deck-it stop`, Restart both. Its detail line is +`deck-it status`, and the buttons wait until it shows the result or 30s pass. + +The daemons are listed in `Services.js`: a label, a piece of the daemon's +`autostart.lua` line and its `pgrep`/`pkill` arguments. Start runs that +enabled line through `hyprctl dispatch hl.dsp.exec_cmd(...)`, as the Autostart +page's Try does, so a `[workspace]` rule applies as at login and the command +lives only in `autostart.lua`; with no enabled line the row says "not in +autostart" and offers no Start. Stop is `pkill`, then up to 5s for the +process to exit, which hyprsunset needs: it holds Hyprland's CTM manager until +it is gone, and a second one dies. Restart is Stop then Start. A `-f` pattern +brackets one letter (`[t]v-mpris\.py`) so it never matches the `sh -c` that +passes it to pgrep or pkill. + +The Hypridle and Hyprsunset settings pages restart their daemon to apply a +save; that is theirs, not a duplicate of these rows. + +Check: `node desktop/modules/services/test_services.js`. diff --git a/desktop/modules/services/Services.js b/desktop/modules/services/Services.js new file mode 100644 index 0000000..d9aab80 --- /dev/null +++ b/desktop/modules/services/Services.js @@ -0,0 +1,43 @@ +// 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. + +.pragma library + +// The daemons the drawer's Services page starts and stops, tested by +// test_services.js under node. +// +// Each is [label, a piece of its autostart.lua line, pgrep/pkill arguments]. +// Its start command is that enabled line, so the command lives only in +// autostart.lua. A -f pattern brackets one letter, so it never matches the +// sh -c that runs pgrep or pkill with the pattern as an argument. +const DAEMONS = [ + ["desktop-assistant", "desktop-assistant/assistant.py", ["-f", "desktop-assistant/[a]ssistant\\.py"]], + ["cal-notif", "cal-notif daemon", ["-f", "[c]al-notif daemon"]], + ["tv-mpris", "tv-mpris.py", ["-f", "[t]v-mpris\\.py"]], + ["mail-watcher", "mail-watcher.sh", ["-f", "[m]ail-watcher\\.sh"]], + ["mail-notify", "mail-notify.sh", ["-f", "[m]ail-notify\\.sh"]], + ["hypridle", "hypridle", ["-x", "hypridle"]], + ["hyprsunset", "hyprsunset", ["-x", "hyprsunset"]], + ["polkit agent", "hyprpolkitagent", ["-x", "hyprpolkitagent"]], + ["notifyd", "notifyd", ["-x", "notifyd"]], + ["playerctld", "playerctld", ["-x", "playerctld"]], + ["conky", "conky", ["-x", "conky"]], + ["clipboard history", "cliphist store", ["-f", "[w]l-paste --watch cliphist"]], +]; + +// [{label, args, start}] from Autostart.js's parsed entries: start is the +// first enabled line holding the daemon's piece, "" when there is none. +function daemons(entries) { + return DAEMONS.map(([label, piece, args]) => { + const e = entries.find(e => e.enabled && e.cmd.includes(piece)); + return { label, args, start: e ? e.cmd : "" }; + }); +} diff --git a/desktop/modules/services/ServicesModule.qml b/desktop/modules/services/ServicesModule.qml new file mode 100644 index 0000000..ffc25fd --- /dev/null +++ b/desktop/modules/services/ServicesModule.qml @@ -0,0 +1,135 @@ +// 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 Quickshell +import Quickshell.Io +import QtQuick +import "../.." +import "../deckit" +import "../autostart/Autostart.js" as A +import "Services.js" as S + +// The drawer's Services: every quickshell shell, deck-it and the desktop's +// daemons, each with Start, Stop and Restart. Their state is read every 2s +// while the page is open. Started detached, so an action outlives the qs that +// started it: restarting the desktop shell from its own drawer works, the +// drawer just closes until the new process is up. +Module { + id: sm + name: "services" + label: "Services" + // nf-fa-refresh, present in Inconsolata Nerd Font. + icon: "" + keywords: ["services", "restart", "reload", "start", "stop", "quickshell", "qs", "shells", + "daemon", "deck-it", "process"] + + readonly property string root: Quickshell.shellDir + "/.." + // [{name, running}], one per directory holding a shell.qml. + property var shells: [] + // [{label, args, start, running}], Services.js's daemons. + property var daemons: [] + property int watchers: 0 + + // An empty name restarts every shell the page lists. A stopped shell + // restarts into a start: reload.sh only starts what is not running. + function restartShell(name) { + Quickshell.execDetached(["sh", Quickshell.shellDir + "/modules/services/restart.sh", sm.root] + .concat(name ? [name] : sm.shells.map(s => s.name))); + repoll.restart(); + } + + function stopShell(name) { + Quickshell.execDetached(["qs", "kill", "-p", sm.root + "/" + name]); + repoll.restart(); + } + + // Stop is pkill, then up to 5s for the process to go: hyprsunset holds + // Hyprland's CTM manager until it exits, and a second one dies. Start runs + // the autostart.lua line through Hyprland, so its [workspace] rule + // applies as at login. + function daemon(d, op) { + const start = op === "stop" || !d.start ? "" : 'hl.dsp.exec_cmd("' + A.quote(d.start) + '")'; + Quickshell.execDetached(["sh", "-c", + 'start=$1; kill=$2; shift 2; ' + + 'if [ "$kill" = 1 ]; then pkill "$@"; ' + + 'for i in $(seq 50); do pgrep "$@" >/dev/null || break; sleep 0.1; done; fi; ' + + '[ -z "$start" ] || hyprctl dispatch "$start"', + "sh", start, op === "start" ? "0" : "1"].concat(d.args)); + repoll.restart(); + } + + function refresh() { + shellProc.rows = []; + shellProc.running = false; + shellProc.running = true; + if (!daemonProc.running) daemonProc.running = true; + } + + // reload.sh waits a second before it returns; read again after that. + property Timer repoll: Timer { + interval: 2000 + onTriggered: sm.refresh() + } + property Timer poll: Timer { + interval: 2000 + repeat: true + running: sm.watchers > 0 + onTriggered: sm.refresh() + } + + property FileView autostart: FileView { + path: DeckIt.autostartFile + watchChanges: true + printErrors: false + onFileChanged: reload() + onLoaded: sm.refresh() + } + + // A shell is running when qs lists an instance on its config path. + property Process shellProc: Process { + property var rows: [] + command: ["sh", "-c", 'cd "$1" || exit 1; up=$(qs list --all 2>/dev/null); ' + + 'for f in */shell.qml; do case "$up" in ' + + '*"Config path: $PWD/$f"*) s=running ;; *) s=stopped ;; esac; ' + + 'printf "%s\\t%s\\n" "${f%/shell.qml}" "$s"; done', "sh", sm.root] + stdout: SplitParser { + onRead: line => { + const f = line.split("\t"); + if (f.length === 2) shellProc.rows.push({ name: f[0], running: f[1] === "running" }); + } + } + onExited: { + sm.shells = shellProc.rows; + sm.searchItems = shellProc.rows.map(s => ({ text: s.name, key: "shell:" + s.name })) + .concat(S.DAEMONS.map(x => ({ text: x[0], key: "daemon:" + x[0] }))); + } + } + + // One 1 or 0 per daemon, in Services.js's order; every daemon has a + // flag and a pattern. + property Process daemonProc: Process { + command: ["sh", "-c", 'while [ $# -gt 1 ]; do pgrep "$1" "$2" >/dev/null && echo 1 || echo 0; shift 2; done', + "sh"].concat([].concat(...S.DAEMONS.map(x => x[2]))) + stdout: StdioCollector { id: daemonOut } + onExited: { + const up = daemonOut.text.split("\n"); + sm.daemons = S.daemons(A.parse(sm.autostart.text())) + .map((d, i) => Object.assign(d, { running: up[i] === "1" })); + } + } + + page: Component { + Page { + title: "Services" + ServicesPage { width: parent.width; services: sm } + } + } +} diff --git a/desktop/modules/services/ServicesPage.qml b/desktop/modules/services/ServicesPage.qml new file mode 100644 index 0000000..cc392db --- /dev/null +++ b/desktop/modules/services/ServicesPage.qml @@ -0,0 +1,92 @@ +// 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 "../.." +import "../ai" +import "../deckit" +import "../qtmaildir" + +// Shells, deck-it and the daemons, one row each: Start when stopped, Stop and +// Restart when running. The desktop shell has no Stop: it draws this page. +Column { + id: page + + required property var services + + spacing: 8 + + Component.onCompleted: { page.services.watchers++; DeckIt.watchers++; page.services.refresh(); } + Component.onDestruction: { page.services.watchers--; DeckIt.watchers--; } + + Heading { text: "Shells" } + + AiRow { + width: page.width + title: "All shells" + detail: "Restarts every one, this drawer included" + on: true + action: "Restart all" + onTriggered: page.services.restartShell("") + } + + Repeater { + model: page.services.shells + + AiRow { + required property var modelData + readonly property bool self: modelData.name === "desktop" + objectName: "shell:" + modelData.name + width: page.width + title: modelData.name + on: modelData.running + detail: (modelData.running ? "Running" : "Stopped") + (self ? " · hosts this drawer" : "") + action: !modelData.running ? "Start" : self ? "" : "Stop" + restartable: modelData.running + onTriggered: modelData.running ? page.services.stopShell(modelData.name) + : page.services.restartShell(modelData.name) + onRestart: page.services.restartShell(modelData.name) + } + } + + Heading { text: "deck-it" } + + AiRow { + width: page.width + title: "deck-it" + detail: ({ start: "Starting…", stop: "Stopping…", restart: "Restarting…" })[DeckIt.busy] ?? DeckIt.summary + on: DeckIt.running + busy: DeckIt.busy !== "" + action: DeckIt.busy ? "" : DeckIt.running ? "Stop" : "Start" + restartable: DeckIt.running && !DeckIt.busy + onTriggered: DeckIt.control(DeckIt.running ? "stop" : "start") + onRestart: DeckIt.control("restart") + } + + Heading { text: "Daemons" } + + Repeater { + model: page.services.daemons + + AiRow { + required property var modelData + objectName: "daemon:" + modelData.label + width: page.width + title: modelData.label + on: modelData.running + detail: modelData.running ? "Running" : modelData.start ? "Stopped" : "Stopped · not in autostart" + action: modelData.running ? "Stop" : modelData.start ? "Start" : "" + restartable: modelData.running && modelData.start !== "" + onTriggered: page.services.daemon(modelData, modelData.running ? "stop" : "start") + onRestart: page.services.daemon(modelData, "restart") + } + } +} diff --git a/desktop/modules/shells/restart.sh b/desktop/modules/services/restart.sh index 2975d41..2975d41 100755 --- a/desktop/modules/shells/restart.sh +++ b/desktop/modules/services/restart.sh diff --git a/desktop/modules/services/test_services.js b/desktop/modules/services/test_services.js new file mode 100644 index 0000000..9f9be4e --- /dev/null +++ b/desktop/modules/services/test_services.js @@ -0,0 +1,46 @@ +// 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. + +// Run: node desktop/modules/services/test_services.js +// Both files are QML libraries, so their .pragma lines are stripped first. + +const fs = require("fs"); +const assert = require("assert"); + +const lib = (f, names) => new Function(fs.readFileSync(f, "utf8").replace(/^\.pragma library$/m, "") + + `\nreturn { ${names} };`)(); +const A = lib(__dirname + "/../autostart/Autostart.js", "parse"); +const S = lib(__dirname + "/Services.js", "daemons, DAEMONS"); + +const entries = A.parse([ + 'hl.on("hyprland.start", function()', + ' hl.exec_cmd("[workspace special:dash silent] conky -c ~/.config/conky/conky.conf")', + ' -- hl.exec_cmd("hypridle")', + ' hl.exec_cmd("python3 -u ~/x/desktop-assistant/assistant.py >> \\"$XDG_RUNTIME_DIR/a.log\\" 2>&1")', + 'end)', +].join("\n")); + +const d = Object.fromEntries(S.daemons(entries).map(x => [x.label, x])); +assert.strictEqual(d.conky.start, "[workspace special:dash silent] conky -c ~/.config/conky/conky.conf"); +assert.strictEqual(d["desktop-assistant"].start, + 'python3 -u ~/x/desktop-assistant/assistant.py >> "$XDG_RUNTIME_DIR/a.log" 2>&1'); +assert.strictEqual(d.hypridle.start, ""); // commented out +assert.strictEqual(d.notifyd.start, ""); // absent +assert.deepStrictEqual(d.hypridle.args, ["-x", "hypridle"]); + +// Every -f pattern matches its line but not itself (the sh running pgrep). +for (const [label, piece, [flag, pat]] of S.DAEMONS) { + if (flag !== "-f") continue; + const re = new RegExp(pat); + assert.ok(!re.test(pat), label + " matches its own pattern"); + assert.ok(re.test(piece) || re.test("wl-paste --watch " + piece), label + " misses its line"); +} +console.log("services ok"); diff --git a/desktop/modules/shells/README.md b/desktop/modules/shells/README.md deleted file mode 100644 index 16a93b5..0000000 --- a/desktop/modules/shells/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# shells - -Every directory in the repo holding a `shell.qml`, with whether `qs list ---all` shows an instance on it, and a Restart (or Start, when it is not -running) per row plus a Restart all. All three run `reload.sh`, so a button -does what the script does from a terminal, wrapped by `restart.sh`, which -then sends one notification naming the shells that came back, or a critical -one naming those that did not. Back means a `qs` instance on the shell's -config path under a pid it did not have before, within 5s: the old instance -can linger in the list for a moment after `qs kill`. It is the process, not -the config: a shell that starts with a broken component counts as back. - -The script is started with `Quickshell.execDetached`, which leaves it outside -the desktop shell's process: restarting `desktop` from here kills the process -drawing the page and the script carries on and starts the new one. The -settings window closes with it and is not reopened. The new shell inherits -the desktop shell's environment, which is the one Hyprland's autostart gave -it. - -A hung desktop shell cannot be restarted from here, since the page is part of -it. `./reload.sh` from a terminal remains the way out. diff --git a/desktop/modules/shells/ShellsModule.qml b/desktop/modules/shells/ShellsModule.qml deleted file mode 100644 index 1a747ac..0000000 --- a/desktop/modules/shells/ShellsModule.qml +++ /dev/null @@ -1,80 +0,0 @@ -// 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 Quickshell -import Quickshell.Io -import QtQuick -import "../.." - -// Every shell in the repo, running or not, with a restart through reload.sh, -// wrapped by restart.sh, which notifies once the shells are back. Started -// detached, so it outlives the qs that started it: -// restarting the desktop shell from its own settings window works, the -// window just closes until the new process is up. -Module { - id: sm - name: "shells" - label: "Shells" - // nf-fa-refresh, present in Inconsolata Nerd Font. - icon: "" - settings: true - group: "Desktop" - keywords: ["restart", "reload", "quickshell", "qs", "process", "start"] - - readonly property string root: Quickshell.shellDir + "/.." - // [{name, running}], one per directory holding a shell.qml. - property var shells: [] - - // An empty name restarts every shell the page lists. - function restart(name) { - Quickshell.execDetached(["sh", Quickshell.shellDir + "/modules/shells/restart.sh", sm.root] - .concat(name ? [name] : sm.shells.map(s => s.name))); - repoll.restart(); - } - - function refresh() { - proc.rows = []; - proc.running = false; - proc.running = true; - } - - // reload.sh waits a second before it returns; read the list after that. - property Timer repoll: Timer { - interval: 2000 - onTriggered: sm.refresh() - } - - // A shell is running when qs lists an instance on its config path. - property Process proc: Process { - property var rows: [] - command: ["sh", "-c", 'cd "$1" || exit 1; up=$(qs list --all 2>/dev/null); ' - + 'for f in */shell.qml; do case "$up" in ' - + '*"Config path: $PWD/$f"*) s=running ;; *) s=stopped ;; esac; ' - + 'printf "%s\\t%s\\n" "${f%/shell.qml}" "$s"; done', "sh", sm.root] - stdout: SplitParser { - onRead: line => { - const f = line.split("\t"); - if (f.length === 2) proc.rows.push({ name: f[0], running: f[1] === "running" }); - } - } - onExited: { - sm.shells = proc.rows; - sm.searchItems = proc.rows.map(s => ({ text: s.name, key: "shell:" + s.name })); - } - } - - page: Component { - Page { - title: "Shells" - ShellsPage { width: parent.width; shells: sm } - } - } -} diff --git a/desktop/modules/shells/ShellsPage.qml b/desktop/modules/shells/ShellsPage.qml deleted file mode 100644 index abbb2b1..0000000 --- a/desktop/modules/shells/ShellsPage.qml +++ /dev/null @@ -1,51 +0,0 @@ -// 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 "../.." -import "../ai" - -// One row per shell, Restart when it runs and Start when it does not, both -// through reload.sh. The desktop row restarts the process drawing this page. -Column { - id: page - - required property var shells - - spacing: 8 - - Component.onCompleted: page.shells.refresh() - - AiRow { - width: page.width - title: "All shells" - detail: "Restarts every one, this window included" - on: true - action: "Restart all" - onTriggered: page.shells.restart("") - } - - Repeater { - model: page.shells.shells - - AiRow { - required property var modelData - objectName: "shell:" + modelData.name - width: page.width - title: modelData.name - on: modelData.running - detail: (modelData.running ? "Running" : "Stopped") - + (modelData.name === "desktop" ? " · hosts this window" : "") - action: modelData.running ? "Restart" : "Start" - onTriggered: page.shells.restart(modelData.name) - } - } -} diff --git a/desktop/shell.qml b/desktop/shell.qml index 9e5183f..a4e2764 100644 --- a/desktop/shell.qml +++ b/desktop/shell.qml @@ -25,7 +25,7 @@ import "modules/deckit" import "modules/island" import "modules/qtmaildir" import "modules/sbbuilder" -import "modules/shells" +import "modules/services" import "modules/bluetooth" import "modules/clipboard" import "modules/fonts" @@ -93,7 +93,7 @@ ShellRoot { ClipboardModule {}, UpdatesModule {}, VmModule {}, - DeckItControlModule {}, + ServicesModule {}, AiModule {}, UserModule {}, NotesModule {}, @@ -109,7 +109,6 @@ ShellRoot { IdleModule {}, NotificationsModule {}, AutostartModule {}, - ShellsModule {}, BindsModule {}, OptionsModule {}, MonitorsModule {}, |
