polybar:launch: Do not parse xrandr for primary

Instead of getting the primary monitor from xrandr we can use the output
of polybars `--list-monitors` that we get already. This results in a
slight performance boost.
This commit is contained in:
2020-10-03 01:57:48 +02:00
parent d0da230266
commit 0ff935663e

View File

@@ -21,13 +21,12 @@ done
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
while read m; do
export TRAY_POS=none
[[ "$m" != "$primary" ]] || export TRAY_POS=right
export MONITOR="$m"
[[ "${m%(primary)}" == "$m" ]] || export TRAY_POS=right
export MONITOR="${m%%:*}"
polybar --reload -c "$BASE_DIR/config" main &
done
done <<<$(polybar --list-monitors)
echo "Polybar launched..."
else