vincentbernat.i3wm-configur.../bin/polybar
Vincent Bernat 7ed896496f polybar: make it compatible with RandR monitors
Other uses of RandR do not need to be aware of monitors. Wallpapers
could be, but it works just fine without that.
2021-08-01 15:30:21 +02:00

21 lines
668 B
Bash
Executable file

#!/bin/sh
export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
export HEIGHT=$((20 * DPI / 96))
MONITORS=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+*]*([^ ]*).*/\2/p')
PRIMARY=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+]?[*]([^ ]*).*/\2/p')
PRIMARY=${PRIMARY:-${MONITORS%% *}}
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