mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-09 17:54:22 +02:00
polybar: avoid querying xrandr for changes too much
For some reason, this makes X probe again the monitors. Switch to `xrandr --current` seems to make this problem goes away. Maybe, this is also `polybar --list-monitors` keeping a grab while polybar is starting.
This commit is contained in:
parent
dfb7cb555e
commit
390597ecd7
1 changed files with 6 additions and 5 deletions
11
bin/polybar
11
bin/polybar
|
@ -3,17 +3,18 @@
|
||||||
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))
|
||||||
|
|
||||||
NUMS=$(polybar --list-monitors | wc -l)
|
MONITORS=$(xrandr --current | awk '($0 ~ / connected / && $0 ~ / [0-9]+x[0-9]+\+/) {print $1}')
|
||||||
PRIMARY=$(polybar --list-monitors | awk -F: '($0 ~ /primary/) {print $1; exit}')
|
PRIMARY=$(xrandr --current | awk '($0 ~ / primary /) {print $1; exit}')
|
||||||
|
NUMS=$(echo $MONITORS | wc -w)
|
||||||
case $NUMS in
|
case $NUMS in
|
||||||
1)
|
1)
|
||||||
MONITOR=$PRIMARY polybar --reload alone &
|
MONITOR=$PRIMARY polybar --reload alone &
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
MONITOR=$PRIMARY polybar --reload primary &
|
MONITOR=$PRIMARY polybar --reload primary &
|
||||||
for MONITOR in $(polybar --list-monitors | awk -F: '($0 !~ /primary/) {print $1}'); do
|
for MONITOR in ${MONITORS}; do
|
||||||
export MONITOR
|
[ $MONITOR != $PRIMARY ] || continue
|
||||||
polybar --reload secondary &
|
MONITOR=$MONITOR polybar --reload secondary &
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue