Repository navigation
Expand file tree
/
Copy pathbeamer
More file actions
executable file
·140 lines (112 loc) · 3.08 KB
/
Copy pathbeamer
File metadata and controls
executable file
·140 lines (112 loc) · 3.08 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
#! /bin/bash
# 2015 Marc Groenewegen
#
# Empirical configure script for projectors
# It works for me, hopefully it will also help others
# xrandr -s 0 ---> reset to defaults
# xrandr -s <resolution>
# LVDS is Macbook display
# DP is Display Port (Macbook)
# Dell XPS
# eDP-1 is laptop
# DP-1 is HDMI
if [ $# -gt 0 ] && [ $1 == "-h" ]; then
echo "-f : forced (forces DP1 to default mode that always works)"
echo "-o : off"
echo "-s : screen (custom)"
exit
fi
# Forced: Macbook Display Port (DP), works everywhere
# N.B.: for other options just modify the script
if [ $# -gt 0 ] && [ $1 == "-f" ]; then
if [ $# -gt 1 ]; then
echo "--FORCED with resolution $2--"
xrandr --addmode DP1 $2
xrandr --output DP1 --mode $2 --right-of LVDS1
else
echo "--FORCED--"
xrandr --addmode DP1 1024x768
xrandr --output DP1 --mode 1024x768 --same-as LVDS1
fi
exit
fi
#
#sudo apt-get install xfonts-100dpi
#
# to fix this error??
# X Error of failed request: BadName (named color or font does not exist)
# 1280x1024 custom
if [ $# -gt 0 ] && [ $1 == "1280" ]; then
echo "--FORCED 1280x1024--"
# cvt 1280 1024
xrandr --newmode "1280" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
xrandr --addmode DP1 1280
xrandr --output DP1 --mode 1280
xrandr --output DP1 --right-of LVDS1
#xrandr --output DP1 --same-as LVDS1
#xrandr --delmode DP1 1131 # detach mode from output
#xrandr --rmmode 1131 # get rid of this mode
exit
fi
# Screen: custom mode
if [ $# -gt 0 ] && [ $1 == "-s" ]; then
echo "--Screen--"
xrandr --output DP-1 --mode 1280x1024
sleep 4
xrandr --output DP-1 --mode 1680x1050
sleep 4
xrandr --output DP-1 --right-of LVDS1
exit
fi
# Off: switch off DP1 and HDMI1
if [ $# -gt 0 ] && [ $1 == "-o" ]; then
echo "--OFF--"
xrandr --output HDMI1 --off
xrandr --output DP1 --off
exit
fi
# Mirror
if [ $# -gt 0 ] && [ $1 == "-m" ]; then
echo "--MIRROR--"
PLACEMENT="--same-as"
else
PLACEMENT="--right-of"
fi
#
# The more flexible solution: let the script search for connected devices
# and offer a list to choose from. NB: if this fails to come up with
# devices use the 'forced' option (see above)
#
NAMES=`xrandr | grep -w connected | awk 'BEGIN {FS=" "} {print $1}'`
# array of output names, start with empty string to fill index 0
OUTPUT=("" ${NAMES})
# show the names with their indexes
echo "Connected outputs"
INDEX=1
for O in ${OUTPUT[*]}; do
echo "$INDEX : $O"
(( INDEX = INDEX + 1 ))
done
((NROFOUTPUTS = INDEX - 1))
echo "Where's the projector?"
read INDEX
if [ $INDEX -gt $NROFOUTPUTS ]; then
echo "Index too large"
exit
fi
echo "Where's the main screen?"
read MAIN
if [ $MAIN -gt $NROFOUTPUTS ]; then
echo "Index too large"
exit
fi
# Ad-hoc
xrandr --output ${OUTPUT[$INDEX]} --mode 1024x768
sleep 4
xrandr --output ${OUTPUT[$INDEX]} --mode 1280x1024
#xrandr --output ${OUTPUT[$INDEX]} --mode 1920x1080
sleep 4
echo xrandr --output ${OUTPUT[$INDEX]} ${PLACEMENT} ${OUTPUT[$MAIN]}
xrandr --output ${OUTPUT[$INDEX]} ${PLACEMENT} ${OUTPUT[$MAIN]}
# to switch projector off:
#echo xrandr --output ${OUTPUT[$INDEX]} --off