mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-24 10:48:35 +02:00
polybar: kill itself if one instance is missing
This commit is contained in:
parent
e54dcc7e6f
commit
2f74d47a74
2 changed files with 11 additions and 2 deletions
|
@ -5,14 +5,16 @@ export HEIGHT=$((18 * DPI / 96))
|
||||||
|
|
||||||
MONITORS=$(polybar --list-monitors | sed -nE 's/([^ ]+): .*/\1/p' | tr '\n' ' ')
|
MONITORS=$(polybar --list-monitors | sed -nE 's/([^ ]+): .*/\1/p' | tr '\n' ' ')
|
||||||
PRIMARY=$(polybar --list-monitors | grep -F '(primary)' | sed -nE 's/([^ ]+): .*/\1/p')
|
PRIMARY=$(polybar --list-monitors | grep -F '(primary)' | sed -nE 's/([^ ]+): .*/\1/p')
|
||||||
|
NMONITORS=$(echo $MONITORS | wc -w)
|
||||||
PRIMARY=${PRIMARY:-${MONITORS%% *}}
|
PRIMARY=${PRIMARY:-${MONITORS%% *}}
|
||||||
|
|
||||||
awk 'BEGIN { i=0 } ($4 == "/" && $3 !~ /^0:/) {print "mount-"i" = "$5; i++}' /proc/self/mountinfo \
|
awk 'BEGIN { i=0 } ($4 == "/" && $3 !~ /^0:/) {print "mount-"i" = "$5; i++}' /proc/self/mountinfo \
|
||||||
> $XDG_RUNTIME_DIR/i3/polybar-filesystems.conf
|
> $XDG_RUNTIME_DIR/i3/polybar-filesystems.conf
|
||||||
|
|
||||||
case $(echo $MONITORS | wc -w) in
|
case $NMONITORS in
|
||||||
1)
|
1)
|
||||||
MONITOR=$PRIMARY polybar --reload alone &
|
MONITOR=$PRIMARY polybar --reload alone &
|
||||||
|
systemd-notify --status="Single polybar instance running on $PRIMARY"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
MONITOR=$PRIMARY polybar --reload primary &
|
MONITOR=$PRIMARY polybar --reload primary &
|
||||||
|
@ -20,5 +22,10 @@ case $(echo $MONITORS | wc -w) in
|
||||||
[ $MONITOR != $PRIMARY ] || continue
|
[ $MONITOR != $PRIMARY ] || continue
|
||||||
MONITOR=$MONITOR polybar --reload secondary &
|
MONITOR=$MONITOR polybar --reload secondary &
|
||||||
done
|
done
|
||||||
|
systemd-notify --status="$NMONITORS polybar instances running"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
systemd-notify --ready
|
||||||
|
trap "systemd-notify WATCHDOG=trigger" CHLD
|
||||||
|
wait
|
||||||
|
|
|
@ -3,7 +3,9 @@ Description=Status bar for i3
|
||||||
PartOf=graphical-session.target
|
PartOf=graphical-session.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=notify
|
||||||
|
NotifyAccess=all
|
||||||
|
WatchdogSignal=SIGTERM
|
||||||
ExecStart=%h/.config/i3/bin/polybar
|
ExecStart=%h/.config/i3/bin/polybar
|
||||||
ExecStop=%h/.local/bin/polybar-msg cmd quit
|
ExecStop=%h/.local/bin/polybar-msg cmd quit
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue