From 81d21f2e335d2fd59f8fc43d4788c2426c8a2fe1 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 28 Oct 2026 09:25:50 +0100 Subject: 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 --- desktop/modules/shells/restart.sh | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 desktop/modules/shells/restart.sh (limited to 'desktop/modules/shells/restart.sh') diff --git a/desktop/modules/shells/restart.sh b/desktop/modules/shells/restart.sh new file mode 100755 index 0000000..2975d41 --- /dev/null +++ b/desktop/modules/shells/restart.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# +# Copyright (C) 2026 Danilo M. +# +# 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. + +# restart.sh ...: reload.sh on the named shells, then one +# notification saying which came back. A shell came back when qs lists an +# instance on its config path under a pid it did not have before, within 5s: +# the old instance can still be listed for a moment after qs kill, and a +# config that fails to load exits rather than lingering. +# +# ponytail: "came back" is the process, not the config. A shell that loads +# with a broken component still counts; its log says so. + +root=$(cd "$1" && pwd) || exit 1 +shift + +# The pids qs lists for 's config path, one per line. +pids() { + qs list --all 2>/dev/null | awk -v p="Config path: $root/$1/shell.qml" ' + /Process ID:/ { id = $3 } index($0, p) { print id }' +} + +old="" +for n; do old="$old $(pids "$n")"; done + +"$root/reload.sh" "$@" >/dev/null 2>&1 + +good="" +bad="" +for n; do + back="" + for _ in 1 2 3 4 5 6 7 8 9 10; do + for p in $(pids "$n"); do + case " $old " in *" $p "*) ;; *) back=1 ;; esac + done + [ -n "$back" ] && break + sleep 0.5 + done + if [ -n "$back" ]; then good="$good $n"; else bad="$bad $n"; fi +done + +if [ -n "$bad" ]; then + notify-send --app-name=Keystone --urgency=critical --icon=dialog-error \ + "Shells" "Did not come back:$bad${good:+. Restarted:$good}" +else + notify-send --app-name=Keystone --icon=dialog-information "Shells" "Restarted:$good" +fi -- cgit v1.2.3