-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathawesome-restart
executable file
·43 lines (37 loc) · 1.21 KB
/
awesome-restart
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
#!/bin/sh
# Restart awesome by signalling the session runner to restart it.
# This loads a new binary.
# The session runner is ./usr/bin/session-run-awesome.sh.
awesome_pid=
for p in $(pgrep -x awesome); do
if grep -q "^DISPLAY=$DISPLAY$" "/proc/$p/environ"; then
echo "Found pid $p for DISPLAY=$DISPLAY."
if [ -n "$awesome_pid" ]; then
echo "ERROR: found multiple pids!? ($awesome_pid, $p) - aborting." >&2
exit 1
fi
awesome_pid=$p
fi
done
[ -z "$awesome_pid" ] && {
echo "No awesome found for DISPLAY=$DISPLAY." >&2
exit 1
}
session_pid=$(ps -o ppid= "$awesome_pid")
[ -z "$session_pid" ] && {
echo "No session PID found for pid $awesome_pid (DISPLAY=$DISPLAY)." >&2
exit 1
}
# echo "Signalling session (USR1), pid=${session_pid}."
kill -USR1 "$session_pid"
# Write args to a file that is read by ~/.dotfiles/usr/bin/session-run-awesome.sh.
# This allows to use another config temporarily, e.g.:
# awesome-restart -c ~/src/awesome/awesomerc.lua
args_file="/var/run/user/$(id -u)/awesome-restart-args"
echo "$@" > "$args_file"
# echo "Sending TERM to awesome: pid=${awesome_pid}."
kill -TERM "$awesome_pid"
sleep 1
if kill -0 "$awesome_pid" 2>/dev/null; then
kill -KILL "$awesome_pid"
fi