From 7ed896496fffebf09e53662fc1c5adae9b297029 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 1 Aug 2021 15:25:53 +0200 Subject: [PATCH] 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. --- bin/polybar | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/polybar b/bin/polybar index 647a692..95d335f 100755 --- a/bin/polybar +++ b/bin/polybar @@ -3,8 +3,8 @@ export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p') export HEIGHT=$((20 * DPI / 96)) -MONITORS=$(xrandr --current | awk '($0 ~ / connected / && $0 ~ / [0-9]+x[0-9]+\+/) {print $1}') -PRIMARY=$(xrandr --current | awk '($0 ~ / connected primary / && $0 ~ / [0-9]+x[0-9]+\+/) {print $1; exit}') +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