-
Notifications
You must be signed in to change notification settings - Fork 2
/
dummyX
executable file
·199 lines (167 loc) · 4.54 KB
/
dummyX
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/bash
# (c) 2020 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/dummyX
#
PROG="${0##*/}"
CWD=$(pwd -P)
XDIR=/tmp
XCONF=xdummy.conf
XLOG=xdummy.log
DISP=$(ps -ef|grep Xorg | grep -vE 'grep|vt[0-9]' | sed 's/.*:\([0-9]*\).*/\1/' | tail -1)
DISPLAY=${DISP:-1000}
RFBPORT=$((DISPLAY + 4901))
XDISP=":$((DISPLAY + 1))"
prereqs() {
for i in x11vnc xfwm4 xfce4-panel xterm xhost;
do
if [ -z "$(which $i)" ]
then
showreqs=1
reqs="${reqs} ${i}"
fi
done
dpkg -l xserver-xorg-video-dummy >/dev/null 2>&1
if [ $? -ne 0 ]
then
showreqs=1
reqs="${reqs} xserver-xorg-video-dummy"
fi
if [ 1 -eq ${showreqs:-0} ]
then
echo "Prerequisites are missing!"
echo "Please make sure the following packages are installed:"
echo ""
echo "xserver-xorg-video-dummy x11vnc xfwm4 xfwm4-themes xfce4-panel xfce4-indicator-plugin xterm x11-xserver-utils"
echo ""
echo "can't find: ${reqs}"
echo ""
exit 1
fi
}
create_xconf() {
cd ${XDIR}
cat >${XCONF} <<EOF
Section "ServerFlags"
Option "DontVTSwitch" "true"
Option "AllowMouseOpenFail" "true"
Option "PciForceNone" "true"
Option "AutoEnableDevices" "false"
Option "AutoAddDevices" "false"
EndSection
Section "InputDevice"
Identifier "dummy_mouse"
Option "CorePointer" "true"
Driver "void"
EndSection
Section "InputDevice"
Identifier "dummy_keyboard"
Option "CoreKeyboard" "true"
Driver "void"
EndSection
Section "Device"
Identifier "VDummy"
Driver "dummy"
#VideoRam 256000
VideoRam 16384
Option "ConstantDPI" "true"
Option "IgnoreEDID" "true"
Option "NoDDC" "true"
EndSection
Section "Monitor"
Identifier "dummy_monitor"
HorizSync 15.0-100.0
VertRefresh 15.0-200.0
Modeline "1920x1080" 23.53 1920 1952 2040 2072 1080 1106 1108 1135
Modeline "1280x1024" 31.50 1280 1312 1424 1456 1024 1048 1052 1076
Modeline "1024x768" 18.71 1024 1056 1120 1152 768 786 789 807
EndSection
Section "Screen"
Identifier "dummy_screen"
Monitor "dummy_monitor"
Device "VDummy"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1920x1080" "1280x1024" "1024x768"
Virtual 1920 1080
EndSubSection
EndSection
Section "ServerLayout"
Identifier "dummy_layout"
Screen "dummy_screen"
InputDevice "dummy_mouse"
InputDevice "dummy_keyboard"
EndSection
EOF
cd ${CWD}
}
fix_perms() {
sed -i 's/^\(allowed_users\)=.*/\1=anybody/g' /etc/X11/Xwrapper.config
}
do_xfwm4() {
# different versions need different calling
xfwm4 --display=${XDISP} 2>/dev/null &
if [ $? -ne 0 ]
then
DISPLAY=${XDISP} xfwm4 2>/dev/null &
fi
}
do_xfce4() {
# different versions need different calling
xfce4-panel --display=${XDISP} 2>/dev/null &
if [ $? -ne 0 ]
then
DISPLAY=${XDISP} xfce4-panel 2>/dev/null &
fi
}
start_xdummy() {
USER=$(/usr/bin/whoami)
HOST=$(/bin/hostname | cut -f 1 -d.)
FBDIR=$(mktemp -d /tmp/vmfbXXXXX)
cd ${XDIR}
/usr/lib/xorg/Xorg -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${XLOG} -configdir ${XDIR} -config ${XCONF} ${XDISP} 2>/dev/null &
sleep 1
cd ${CWD}
# This is broken, so we manually do things - but then we can't "logout" which... is fine?
# ( export DISPLAY=${XDISP}; startxfce4 DISPLAY=${XDISP} ) &
# sleep 1
xterm -ls -sl 1000 -sb -T ${USER}@${HOST} -fg white -bg black -C -fn 9x15 -display ${XDISP} 2>/dev/null &
sleep 1
do_xfwm4
sleep 1
do_xfce4
sleep 1
DISPLAY=${XDISP} xhost +localhost
x11vnc -q -rfbport ${RFBPORT} -forever -alwaysshared -bg -nopw -display ${XDISP}
}
start() {
create_xconf
start_xdummy
}
stop() {
rm -f ${XCONF}
PIDS=$(pgrep -la Xorg | grep xdummy | awk '{print $1}')
for PID in $PIDS
do
kill ${PID}
done
}
status() {
pgrep -la Xorg | grep xdummy
[[ $? -eq 1 ]] && echo "${PROG} is not running (no xorg-dummy processes found)"
}
case ${1} in
start) prereqs; start
;;
stop) stop
;;
prep) create_xconf
;;
status) prereqs; status
;;
*) echo "$0 [start|stop|status]"
;;
esac