mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-09 09:44:20 +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' ' ')
|
||||
PRIMARY=$(polybar --list-monitors | grep -F '(primary)' | sed -nE 's/([^ ]+): .*/\1/p')
|
||||
NMONITORS=$(echo $MONITORS | wc -w)
|
||||
PRIMARY=${PRIMARY:-${MONITORS%% *}}
|
||||
|
||||
awk 'BEGIN { i=0 } ($4 == "/" && $3 !~ /^0:/) {print "mount-"i" = "$5; i++}' /proc/self/mountinfo \
|
||||
> $XDG_RUNTIME_DIR/i3/polybar-filesystems.conf
|
||||
|
||||
case $(echo $MONITORS | wc -w) in
|
||||
case $NMONITORS in
|
||||
1)
|
||||
MONITOR=$PRIMARY polybar --reload alone &
|
||||
systemd-notify --status="Single polybar instance running on $PRIMARY"
|
||||
;;
|
||||
*)
|
||||
MONITOR=$PRIMARY polybar --reload primary &
|
||||
|
@ -20,5 +22,10 @@ case $(echo $MONITORS | wc -w) in
|
|||
[ $MONITOR != $PRIMARY ] || continue
|
||||
MONITOR=$MONITOR polybar --reload secondary &
|
||||
done
|
||||
systemd-notify --status="$NMONITORS polybar instances running"
|
||||
;;
|
||||
esac
|
||||
|
||||
systemd-notify --ready
|
||||
trap "systemd-notify WATCHDOG=trigger" CHLD
|
||||
wait
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue