forked from xonotic/xonotic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxonotic-linux-glx.sh
executable file
·131 lines (116 loc) · 2.3 KB
/
xonotic-linux-glx.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
#!/bin/sh
path=`dirname "${0}"`
link=`readlink -f "${0}"`
[ -n "${link}" ] && path=`dirname "${link}"`
cd "${path}"
case "${0##*/}" in
*dedicated*) mode="dedicated" ;;
*sdl*) mode="sdl" ;;
*) mode="glx" ;;
esac
case "$(uname -m)" in
x86_64) arch="linux64" ;;
*) arch="linux32" ;;
esac
xonotic="xonotic-${arch}-${mode}"
set -- ./${xonotic} "${@}"
xserver=
xlayout=
setdisplay()
{
VALUE=$1
VALUE=${VALUE#\"}
VALUE=${VALUE%\"}
case "$VALUE" in
:*)
;;
*)
VALUE=:$VALUE
;;
esac
VALUE="$VALUE/"
xserver="${VALUE%%/*}"
xserver=${xserver#:}
xlayout=${VALUE#*/}
xlayout=${xlayout%/}
}
# now how do we execute it?
if [ -r ~/.xonotic/data/config.cfg ]; then
while read -r CMD KEY VALUE; do
case "$CMD:$KEY" in
seta:vid_x11_display)
setdisplay "$VALUE"
;;
esac
done < ~/.xonotic/data/config.cfg
fi
m=0
for X in "$@"; do
case "$m:$X" in
0:+vid_x11_display)
m=1
;;
0:+vid_x11_display\ *)
setdisplay "${X#+vid_x11_display }"
;;
1:*)
setdisplay "$X"
m=0
;;
*)
;;
esac
done
case "$xserver" in
'')
;;
*[!0-9]*)
echo "Not using display ':$xserver': evil characters"
;;
*)
msg=
lf='
'
prefix=
# check for a listening X server on that socket
if netstat -nl | grep -F " /tmp/.X11-unix/X$xserver" >/dev/null; then
# X server already exists
export DISPLAY=:$xserver
prefix="DISPLAY=:$xserver "
msg=$msg$lf"- Running Xonotic on already existing display :$xserver"
else
set -- startx "$@" -fullscreen -- ":$xserver"
msg=$msg$lf"- Running Xonotic on a newly created X server :$xserver."
case "$xlayout" in
'')
;;
*[!A-Za-z0-9]*)
echo >&2 "Not using layout '$xlayout': evil characters"
xlayout=
;;
*)
set -- "$@" -layout "$xlayout"
msg=$msg$lf"- Using the ServerLayout section named $xlayout."
;;
esac
fi
echo "X SERVER OVERRIDES IN EFFECT:$msg"
echo
echo "Resulting command line:"
echo " $prefix$*"
echo
echo "To undo these overrides, edit ~/.xonotic/data/config.cfg and remove the line"
echo "starting with 'seta vid_x11_display'."
echo
echo
;;
esac
# if pulseaudio
if [ -z "$SDL_AUDIODRIVER" ]; then
if ps -C pulseaudio >/dev/null; then
if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
export SDL_AUDIODRIVER=pulse
fi
fi
fi
exec "$@"