polybar: handle alone/primary/secondary configurations

This commit is contained in:
Vincent Bernat 2021-07-08 08:10:37 +02:00
parent 3909defef4
commit a3ffbddf82
2 changed files with 26 additions and 10 deletions

View file

@ -5,10 +5,18 @@ export WLAN=$(nmcli -t device | awk -F: '($2 == "wifi") {print $1; exit}')
export DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
export HEIGHT=$((20 * DPI / 96))
MONITOR=$(polybar --list-monitors | awk -F: '($0 ~ /primary/) {print $1; exit}') \
polybar --reload primary &
for MONITOR in $(polybar --list-monitors | awk -F: '($0 !~ /primary/) {print $1}'); do
export MONITOR
polybar --reload secondary &
done
NUMS=$(polybar --list-monitors | wc -l)
PRIMARY=$(polybar --list-monitors | awk -F: '($0 ~ /primary/) {print $1; exit}')
case $NUMS in
1)
MONITOR=$PRIMARY polybar --reload alone &
;;
*)
MONITOR=$PRIMARY polybar --reload primary &
for MONITOR in $(polybar --list-monitors | awk -F: '($0 !~ /primary/) {print $1}'); do
export MONITOR
polybar --reload secondary &
done
;;
esac
wait

View file

@ -6,7 +6,7 @@ highlight = #4c7899
[settings]
screenchange-reload = false
[bar/secondary]
[bar/common]
enable-ipc = true
width = 100%
height = ${env:HEIGHT:}
@ -27,11 +27,19 @@ font-1 = Font Awesome 5 Pro:style=Solid:size=10;2
font-2 = Font Awesome 5 Brands:style=Regular:size=10;2
modules-left = i3
modules-right = pulseaudio date
[bar/alone]
inherit = bar/common
modules-right = cpu memory brightness battery ethernet wlan pulseaudio date
[bar/primary]
inherit = bar/secondary
modules-right = cpu memory pulseaudio brightness battery ethernet wlan date
inherit = bar/common
modules-right = cpu memory brightness battery pulseaudio date
[bar/secondary]
inherit = bar/common
modules-right = ethernet wlan pulseaudio date
[module/i3]
type = internal/i3