diff --git a/bin/polybar b/bin/polybar index d0d3014..54826f0 100755 --- a/bin/polybar +++ b/bin/polybar @@ -3,8 +3,8 @@ 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' | tr '\n' ' ') -PRIMARY=$(polybar --list-monitors | grep -F '(primary)' | sed -nE 's/([^ ]+): .*/\1/p') +MONITORS=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+*]*([^ ]*).*/\2/p' | tr '\n' ' ') +PRIMARY=$(xrandr --current --listactivemonitors | sed -nE 's/ *([0-9]+): [+]?[*]([^ ]*).*/\2/p') NMONITORS=$(echo $MONITORS | wc -w) PRIMARY=${PRIMARY:-${MONITORS%% *}}