From e9e222f6fa81378afd45652c3a30aeccdb0c7e9e Mon Sep 17 00:00:00 2001 From: noctuid Date: Thu, 22 Dec 2016 13:38:32 -0500 Subject: [PATCH] Ignore disabled monitors for -m Don't check monitors without dimensions in xrandr's output. Addresses #26. --- tdrop | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tdrop b/tdrop index d2ea7a2..1912656 100755 --- a/tdrop +++ b/tdrop @@ -244,16 +244,18 @@ update_geometry_settings_for_monitor() { monitors_info=$(xrandr --query | awk '/ connected/ {gsub("primary ",""); print}') while read -r monitor; do monitor_geo=$(echo "$monitor" | awk '{print $3}') - x_begin=$(echo "$monitor_geo" | awk -F '+' '{print $2}') - y_begin=$(echo "$monitor_geo" | awk -F '+' '{print $3}') - x_width=$(echo "$monitor_geo" | awk -F 'x' '{print $1}') - y_height=$(echo "$monitor_geo" | awk -F 'x|+' '{print $2}') - x_end=$((x_begin+x_width)) - y_end=$((y_begin+y_height)) - if [[ $window_x -ge $x_begin ]] && [[ $window_x -lt $x_end ]] && \ - [[ $window_y -ge $y_begin ]] && [[ $window_y -lt $y_end ]]; then - current_monitor=$(echo "$monitor" | awk '{print $1}') - break + if [[ $monitor_geo =~ ^[0-9]+x[0-9]+\+[0-9]+\+[0-9]+$ ]]; then + x_begin=$(echo "$monitor_geo" | awk -F '+' '{print $2}') + y_begin=$(echo "$monitor_geo" | awk -F '+' '{print $3}') + x_width=$(echo "$monitor_geo" | awk -F 'x' '{print $1}') + y_height=$(echo "$monitor_geo" | awk -F 'x|+' '{print $2}') + x_end=$((x_begin+x_width)) + y_end=$((y_begin+y_height)) + if [[ $window_x -ge $x_begin ]] && [[ $window_x -lt $x_end ]] && \ + [[ $window_y -ge $y_begin ]] && [[ $window_y -lt $y_end ]]; then + current_monitor=$(echo "$monitor" | awk '{print $1}') + break + fi fi done <<< "$monitors_info" fi