diff --git a/bin/polybar b/bin/polybar index 591c06c..d0d3014 100755 --- a/bin/polybar +++ b/bin/polybar @@ -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 diff --git a/dotfiles/systemd/polybar.service b/dotfiles/systemd/polybar.service index 51f6c79..dc030e6 100644 --- a/dotfiles/systemd/polybar.service +++ b/dotfiles/systemd/polybar.service @@ -3,7 +3,9 @@ Description=Status bar for i3 PartOf=graphical-session.target [Service] -Type=forking +Type=notify +NotifyAccess=all +WatchdogSignal=SIGTERM ExecStart=%h/.config/i3/bin/polybar ExecStop=%h/.local/bin/polybar-msg cmd quit Restart=on-failure