diff --git a/.local/bin/displayselect b/.local/bin/displayselect index 682762e..2c82225 100755 --- a/.local/bin/displayselect +++ b/.local/bin/displayselect @@ -16,7 +16,7 @@ twoscreen() { # If multi-monitor is selected and there are two screens. # version for the internal display if [ "$mirror" = "yes" ]; then external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:") - internal=$(echo "$screens" | grep -v "$external") + internal=$(echo "$screens" | grep -v -w "$external") res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \ tail -n 1 | awk '{print $1}') @@ -46,24 +46,24 @@ twoscreen() { # If multi-monitor is selected and there are two screens. morescreen() { # If multi-monitor is selected and there are more than two screens. primary=$(echo "$screens" | dmenu -i -p "Select primary display:") - secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:") + secondary=$(echo "$screens" | grep -v -w "$primary" | dmenu -i -p "Select secondary display:") direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") - tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:") + tertiary=$(echo "$screens" | grep -v -w "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:") xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto } multimon() { # Multi-monitor handler. case "$(echo "$screens" | wc -l)" in - 1) xrandr $(echo "$allposs" | grep -v "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; + 1) xrandr $(echo "$allposs" | grep -v -w "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; 2) twoscreen ;; *) morescreen ;; esac ;} # Get all possible displays -allposs=$(xrandr -q | grep "connected") +allposs=$(xrandr -q | grep -w "connected") # Get all connected screens. -screens=$(echo "$allposs" | grep " connected" | awk '{print $1}') +screens=$(echo "$allposs" | awk '{print $1}') # Get user choice including multi-monitor and manual selection: chosen=$(printf "multi-monitor\\n%s\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&