From 0ff935663e6987c02f4ae7e6f3e1464c7bd37648 Mon Sep 17 00:00:00 2001 From: druckdev <63563978+druckdev@users.noreply.github.com> Date: Sat, 3 Oct 2020 01:57:48 +0200 Subject: [PATCH] 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. --- .config/polybar/launch.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.config/polybar/launch.sh b/.config/polybar/launch.sh index d0a4b35..35fb6da 100755 --- a/.config/polybar/launch.sh +++ b/.config/polybar/launch.sh @@ -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