-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_xrandr
executable file
·126 lines (120 loc) · 2.44 KB
/
my_xrandr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
#POSITION="--above"
POSITION="--right-of"
if [ "$(xrandr | grep -c " connected")" -lt 2 ]
then
echo "You seem to only have 1 display connected, we are bailing out"
exit 1
fi
DVI=$(xrandr | grep \ connected | awk '{ print $1 }' | grep DVI)
HDMI=$(xrandr | grep \ connected | awk '{ print $1 }' | grep HDMI)
DP=$(xrandr | grep \ connected | awk '{ print $1 }' | grep DisplayPort)
if [[ "$DP" != "" ]]
then
main="$DP"
else
main="$HDMI"
fi
if [ -z "$2" ]
then
RES="1920x1080"
else
case $2 in
hd)
RES="1920x1080"
;;
qhd)
RES="2560x1440"
;;
uhd)
RES="3840x2160"
esac
fi
case $1 in
hdmi_on)
if [ "$HDMI" != "" ]
then
xrandr --output "$HDMI" --mode "$RES" --same-as "$main"
else
echo "We aren't running this since you have no HDMI display connected."
fi
;;
hdmi_off)
if [ "$HDMI" != "" ]
then
xrandr --output "$HDMI" --off
else
echo "We aren't running this since you have no HDMI display connected."
fi
;;
dp_on)
if [ "$DP" != "" ]
then
xrandr --output "$DP" --primary --output "$DP" --mode "$RES"
else
echo "We aren't running this since you have no DP display connected."
fi
;;
dp_off)
if [ "$DP" != "" ]
then
xrandr --output "$DP" --off
else
echo "We aren't running this since you have no DP display connected."
fi
;;
dvi_on)
if [ "$DVI" != "" ]
then
for i in $DVI
do
xrandr --output "$i" --mode "$RES" "$POSITION" "$main"
done
else
echo "We aren't running this since you have no DVI display connected."
fi
;;
dvi_off)
if [ "$DVI" != "" ]
then
for i in $DVI
do
xrandr --output "$i" --off
done
else
echo "We aren't running this since you have no DVI display connected."
fi
;;
dvi_portrait)
if [ "$DVI" != "" ]
then
for i in $DVI
do
xrandr --output "$DVI" --auto --rotate left --output "$DVI" "$POSITION" "$main"
done
else
echo "We aren't running this since you have no DVI display connected."
fi
;;
*)
echo "This script assumes three monitors are connected."
echo "Unexpected behavior may occur when disabling the display port device."
echo ""
echo "You must supply an argument."
echo "Options are:"
echo " hdmi_on"
echo " hdmi_off"
echo " dp_on"
echo " dp_off"
echo " dvi_on"
echo " dvi_off"
echo " dvi_portrait"
echo ""
echo "To change resolution, provide a second option:"
echo " hd"
echo " qhd"
echo " uhd"
echo ""
echo "Example:"
echo " ./my_xrandr hdmi_on uhd"
esac