9
9
# xrandr --output HDMI1 --auto --mode 1440x900 --same-as eDP1
10
10
11
11
INPUT=" eDP1"
12
- OUTPUT=$( xrandr | grep " connected" | grep -v ${INPUT} | cut -f 1 -d " " )
12
+ OUTPUT=$( xrandr | grep " connected" | grep -v " ^ ${INPUT} " | cut -f 1 -d " " )
13
13
14
14
if [ -z $1 ]; then
15
- INPUT_RES=$( xrandr | grep -A1 ${INPUT} | tail -n 1 | awk ' {print $1}' )
16
- RES=$( xrandr | grep -A15 ${OUTPUT} | grep -B15 " connected" | awk ' {print $1}' | grep " [0-9][0-9][0-9]x[0-9][0-9][0-9]" )
15
+ INPUT_RES=$( xrandr | grep -A1 " ^ ${INPUT} " | tail -n 1 | awk ' {print $1}' )
16
+ RES=$( xrandr | grep -A15 " ^ ${OUTPUT} " | grep -B15 " connected" | awk ' {print $1}' | grep " [0-9][0-9][0-9]x[0-9][0-9][0-9]" )
17
17
echo " Available OUTPUT resolutions:"
18
18
echo " $RES "
19
19
# choose the biggest supported resolution that is smaller than INPUT_RES
@@ -36,7 +36,7 @@ if [ -z $1 ]; then
36
36
echo " If you are not happy with the results try to specify the resolution manually"
37
37
echo " example: $0 <resolution>"
38
38
echo
39
- OUTPUT_RES=$( xrandr | grep -A1 ${OUTPUT} | tail -n 1 | awk ' {print $1}' )
39
+ OUTPUT_RES=$( xrandr | grep -A1 " ^ ${OUTPUT} " | tail -n 1 | awk ' {print $1}' )
40
40
fi
41
41
else
42
42
OUTPUT_RES=$1
47
47
48
48
if [ " $1 " == " -u" ]; then
49
49
# undo (left-of: my home setup)
50
- INPUT_RES=$( xrandr | grep -A1 ${INPUT} | tail -n 1 | awk ' {print $1}' )
50
+ INPUT_RES=$( xrandr | grep -A1 " ^ ${INPUT} " | tail -n 1 | awk ' {print $1}' )
51
51
echo " INPUT: ${INPUT} (${INPUT_RES} )"
52
- OUTPUT_RES=$( xrandr | grep -A1 ${OUTPUT} | tail -n 1 | awk ' {print $1}' )
52
+ OUTPUT_RES=$( xrandr | grep -A1 " ^ ${OUTPUT} " | tail -n 1 | awk ' {print $1}' )
53
53
echo " OUTPUT: ${OUTPUT} (${OUTPUT_RES} )"
54
54
xrandr --output ${INPUT} --auto --mode ${INPUT_RES} --output ${OUTPUT} --auto --mode ${OUTPUT_RES} --left-of ${INPUT}
55
55
else
0 commit comments