When restarting i3 check for connected second monitor: scale it and restart polybar if there is one. Put polybar tray on the main monitor. Do not kill polybar and relaunch it when restarting i3, but restart it using ipc (much faster).
19 lines
529 B
Bash
Executable File
19 lines
529 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# if there is no running instance
|
|
if ! pgrep -ax polybar >/dev/null 2>&1; then
|
|
# launch Polybar on every monitor
|
|
# https://github.com/polybar/polybar/issues/763
|
|
primary="$(xrandr -q | grep primary | cut -d' ' -f1)"
|
|
for m in $(polybar --list-monitors | cut -d':' -f1); do
|
|
export TRAY_POS=none
|
|
[ "$m" != "$primary" ] || export TRAY_POS=right
|
|
export MONITOR="$m"
|
|
polybar --reload -c "${XDG_CONFIG_HOME:-$HOME/.config}/polybar/config" main &
|
|
done
|
|
|
|
echo "Polybar launched..."
|
|
else
|
|
polybar-msg cmd restart
|
|
fi
|