summaryrefslogtreecommitdiffstats
path: root/desktop/modules/shells/ShellsModule.qml
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-28 09:25:50 +0100
committerDanilo M. <danix@danix.xyz>2026-10-28 09:25:50 +0100
commit81d21f2e335d2fd59f8fc43d4788c2426c8a2fe1 (patch)
treebddfb5bc82db54496b1d4a7b44793d9d6c7ac41a /desktop/modules/shells/ShellsModule.qml
parent11c4c745c7ed5477c74abe7de3458924a0567a3a (diff)
downloadquickshell-81d21f2e335d2fd59f8fc43d4788c2426c8a2fe1.tar.gz
quickshell-81d21f2e335d2fd59f8fc43d4788c2426c8a2fe1.zip
shells: a settings page that restarts the shells, with a notification
Settings > Desktop > Shells lists every directory holding a shell.qml, running or stopped by `qs list --all`, with Restart (Start when it is not running) per row and a Restart all. Every button runs reload.sh through Quickshell.execDetached, which leaves the script outside the desktop shell's process, so restarting desktop from its own settings window works: the window closes and the new process carries on. restart.sh wraps reload.sh and sends one notification naming the shells that came back, or a critical one naming those that did not. Back means qs lists an 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 checks the process, not the config, so a shell that starts with a broken component still counts as back. The rows reuse the ai module's AiRow rather than a copy of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/shells/ShellsModule.qml')
-rw-r--r--desktop/modules/shells/ShellsModule.qml80
1 files changed, 80 insertions, 0 deletions
diff --git a/desktop/modules/shells/ShellsModule.qml b/desktop/modules/shells/ShellsModule.qml
new file mode 100644
index 0000000..1a747ac
--- /dev/null
+++ b/desktop/modules/shells/ShellsModule.qml
@@ -0,0 +1,80 @@
+// 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 }
+ }
+ }
+}