-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.sh
executable file
·147 lines (123 loc) · 4.21 KB
/
setup.sh
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
140
141
142
143
144
145
146
#!/bin/bash
# requirements
# width
# height
# refresh_rate
# position
# password
echo
echo "/////////////////////////////////////////////"
echo "// //"
echo "// screen-extensio //"
echo "// //"
echo "///////////////////////////////////////////"
echo
echo "-----------------------"
echo " Running check-pkg.sh "
echo "-----------------------"
sudo ./check-pkg.sh
echo
while true; do
read -p 'Display width: ' width
read -p 'Display height: ' height
read -p 'refresh_rate: ' refresh_rate
read -p 'Choose the position of your new monitor (0 for right, 1 for left, 2 for bottom, 3 for top): ' position
while true; do
read -sp 'Password: ' password
echo
read -sp "Confirm Password: " confirm_pass
echo
if [ ${password} != ${confirm_pass} ]; then
echo " xxxx Password doesnt match xxxx "
else
break
fi
done
echo "---------------------------------------"
read -p "Please confirm your answers by entering 'Y' or 'n': " confirm
if [ "${confirm}" == 'Y' ];
then
break
else
echo " zzzzz try again zzzzz "
continue
fi
done
modeline=$(gtf ${width} ${height} ${refresh_rate} | sed -n '3 p'| sed 's/ Modeline//')
resolution=${width}x${height}_${refresh_rate}.00
positions=('--right-of' '--left-of' '--below' '--top')
current_output=$(xrandr --listmonitors | awk '{print $4}'| awk 'NR==2{print $1}')
user_path=/home/$(whoami)
echo "Creating folder for 'vnc'.."
mkdir ~/.vnc
echo
echo "Saving your password..."
x11vnc -storepasswd ${password} ~/.vnc/password
# create app folder
echo "creating folder '~/.screen-extensio'"
mkdir ~/.screen-extensio
echo
# create app start executable
echo "creating startvnc executable '~/.screen-extensio/startvnc.sh'"
touch ~/.screen-extensio/startvnc.sh
cat > ~/.screen-extensio/startvnc.sh <<EOL
#!/bin/bash
xrandr --newmode ${modeline}
xrandr --addmode VIRTUAL1 ${resolution}
xrandr --output VIRTUAL1 --mode ${resolution} ${positions[${position}]} ${current_output}
adb reverse tcp:5900 tcp:5900
x11vnc -usepw -clip ${width}x${height}+0+0
echo "Please enter the following details in your VNC app-"
echo " 1) IP Address: localhost "
echo " 2) VNC Password: "
echo " 3) Port (optional): 5900"
echo "Run program 'Close VNC' to close vnc"
EOL
echo
# creat app close executable
echo "creating close vnc executable '~/.screen-extensio/closevnc.sh'"
cat > ~/.screen-extensio/closevnc.sh <<EOL
#!/bin/bash
adb kill-server
killall x11vnc
xrandr --output VIRTUAL1 --off
xrandr --delmode VIRTUAL1 "${width}x${height}_${refresh_rate}.00"
xrandr --rmmode "${width}x${height}_${refresh_rate}.00"
EOL
echo
# creating desktop shortcut for startvnc.sh
echo "creating startvnc shortcut '~/.local/share/applications/startvnc.desktop'"
cat > ~/.local/share/applications/startvnc.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Exec=${user_path}/.screen-extensio/startvnc.sh
Name=Start VNC
Icon=cs-screen
EOL
echo
# creating closevnc shortcut
echo "creating closevnc shortcut '~/.local/share/applications/closevnc.desktop'"
cat > ~/.local/share/applications/closevnc.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Exec=${user_path}/.screen-extensio/closevnc.sh
Name=Close VNC
Icon=cs-screen
EOL
echo
# making scripts executable
echo " Making scripts 'startvnc.sh' 'closevnc.sh' 'startvnc.desktop' 'closevnc.desktop' 'uninstall.sh' executable"
sudo chmod +x ~/.screen-extensio/startvnc.sh ~/.screen-extensio/closevnc.sh ~/.local/share/applications/startvnc.desktop ~/.local/share/applications/closevnc.desktop uninstall.sh
echo 'application setup complete.'
echo '++++ You can now run the program named "Start VNC" to start the vnc server! ++++'
echo
echo '!!! note that you have to connect your android device and enable usb-debugging before continuing...'
echo 'Make sure that both the devices are connected to the same network! Please enable USB-Tethering for faster performance...!!!'
echo
echo "---- You can stop the vnc by running the program 'Close VNC'! ----"