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.
This commit is contained in:
Vincent Bernat 2021-08-01 15:25:53 +02:00
parent 325d7778d7
commit 7ed896496f

View file

@ -3,8 +3,8 @@
export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p') export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
export HEIGHT=$((20 * DPI / 96)) export HEIGHT=$((20 * DPI / 96))
MONITORS=$(xrandr --current | awk '($0 ~ / connected / && $0 ~ / [0-9]+x[0-9]+\+/) {print $1}') MONITORS=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+*]*([^ ]*).*/\2/p')
PRIMARY=$(xrandr --current | awk '($0 ~ / connected primary / && $0 ~ / [0-9]+x[0-9]+\+/) {print $1; exit}') PRIMARY=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+]?[*]([^ ]*).*/\2/p')
PRIMARY=${PRIMARY:-${MONITORS%% *}} PRIMARY=${PRIMARY:-${MONITORS%% *}}
case $(echo $MONITORS | wc -w) in case $(echo $MONITORS | wc -w) in