2021-07-04 18:25:28 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
|
2021-08-07 21:09:10 +02:00
|
|
|
export HEIGHT=$((18 * DPI / 96))
|
2021-07-04 18:25:28 +02:00
|
|
|
|
2021-08-23 10:16:03 +02:00
|
|
|
MONITORS=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+*]*([^ ]*).*/\2/p' | tr '\n' ' ')
|
|
|
|
PRIMARY=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+]?[*]([^ ]*).*/\2/p')
|
2021-08-22 08:59:43 +02:00
|
|
|
NMONITORS=$(echo $MONITORS | wc -w)
|
2021-07-15 19:12:36 +02:00
|
|
|
PRIMARY=${PRIMARY:-${MONITORS%% *}}
|
2021-07-15 20:52:32 +02:00
|
|
|
|
2021-08-02 22:59:26 +02:00
|
|
|
awk 'BEGIN { i=0 } ($4 == "/" && $3 !~ /^0:/) {print "mount-"i" = "$5; i++}' /proc/self/mountinfo \
|
|
|
|
> $XDG_RUNTIME_DIR/i3/polybar-filesystems.conf
|
|
|
|
|
2021-08-22 08:59:43 +02:00
|
|
|
case $NMONITORS in
|
2021-07-08 08:10:37 +02:00
|
|
|
1)
|
2021-07-17 11:09:04 +02:00
|
|
|
MONITOR=$PRIMARY polybar --reload alone &
|
2021-08-22 08:59:43 +02:00
|
|
|
systemd-notify --status="Single polybar instance running on $PRIMARY"
|
2021-07-08 08:10:37 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
MONITOR=$PRIMARY polybar --reload primary &
|
2021-07-15 14:32:00 +02:00
|
|
|
for MONITOR in ${MONITORS}; do
|
|
|
|
[ $MONITOR != $PRIMARY ] || continue
|
|
|
|
MONITOR=$MONITOR polybar --reload secondary &
|
2021-07-08 08:10:37 +02:00
|
|
|
done
|
2021-08-22 08:59:43 +02:00
|
|
|
systemd-notify --status="$NMONITORS polybar instances running"
|
2021-07-08 08:10:37 +02:00
|
|
|
;;
|
|
|
|
esac
|
2021-08-22 08:59:43 +02:00
|
|
|
|
|
|
|
systemd-notify --ready
|
|
|
|
trap "systemd-notify WATCHDOG=trigger" CHLD
|
|
|
|
wait
|