vincentbernat.i3wm-configur.../bin/polybar
Vincent Bernat 62a831ac40 polybar: fix monitor detection on clone
Polybar knows how to do that, let's just use polybar --list-monitors.
2021-08-14 20:51:29 +02:00

24 lines
782 B
Bash
Executable file

#!/bin/sh
export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
export HEIGHT=$((18 * DPI / 96))
MONITORS=$(polybar --list-monitors | sed -nE 's/([^ ]+): .*/\1/p')
PRIMARY=$(polybar --list-monitors | grep -F '(primary)' | sed -nE 's/([^ ]+): .*/\1/p')
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
1)
MONITOR=$PRIMARY polybar --reload alone &
;;
*)
MONITOR=$PRIMARY polybar --reload primary &
for MONITOR in ${MONITORS}; do
[ $MONITOR != $PRIMARY ] || continue
MONITOR=$MONITOR polybar --reload secondary &
done
;;
esac