blob: 2975d4150a22822e3c617d019a2e40337b0864eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!/bin/sh
#
# 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.
# restart.sh <repo> <shell>...: 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 <shell>'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
|