This repository was archived by the owner on Jul 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunKSP.sh
More file actions
181 lines (138 loc) · 3.7 KB
/
Copy pathrunKSP.sh
File metadata and controls
181 lines (138 loc) · 3.7 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
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
#!/bin/bash
KSPpath=""
prePath="/mnt/...." #change this to your preference (i have several sub-folders, so the pre-folder is the same)
#if you add/remove, you have to edit the zenity-response variable below
Kpaths[0]="Kerbal Space Program_current"
Kpaths[1]="Kerbal Space Program_test"
Kpaths[2]="Kerbal Space Program_1.1.2"
Kpaths[3]="Kerbal Space Program_1.1.3"
Kpaths[4]="Kerbal Space Program_1.2.1"
maxPathes=${#Kpaths[@]}
KSPapp="KSP.x86"
found64bit=false
if [ "$(uname -m)" = "x86_64" ]; then
KSPapp=$KSPapp"_64"
found64bit=true
fi
#possible params --> -force-opengl -force-opengl -force-gfx-direct
kspParams=" -force-opengl"
# kspParams=""
preRun="" # preRun="taskset -c 2-3 " --> forcing to set other cpu cores (for me it was not quite performance improving)
goAhead=true
optionID=0
kspPID=0
clear
info=""
msg="32bit"
if [ "$found64bit" = true ]; then
msg="64bit"
fi
info="NOTE: found $msg OS $(uname -s), using '$KSPapp$kspParams' if you choose to start KSP"
echo "$info"
optionID=0
options[0]=""
optionsStr=""
idx=0
# ${#Kpaths[@]}
while [ $idx -lt $maxPathes ]; do
options[$idx]="$prePath${Kpaths[$idx]}"
if [ $idx = $(($maxPathes -1)) ]; then
optionsStr="$optionsStr${options[$idx]}"
else
optionsStr="$optionsStr${options[$idx]}|"
fi
let idx=idx+1
# idx=$(($idx + 1))
done
echo ""
echo "[:: KSP Launcher | pick path ::]"
echo ""
echo "--> Wich folder you wish to use?"
response=$(zenity --title="[:: KSP Launcher | pick path ::]" --width=600 --height=250 --list --radiolist --text="$info" \
--column="" --column="Wich folder you wish to use?" \
TRUE "${options[0]}" FALSE "${options[1]}" FALSE "${options[2]}" FALSE "${options[3]}" FALSE "${options[4]}")
case "$response" in
${options[0]} )
optionID=1 ;;
${options[1]} )
optionID=2 ;;
${options[2]} )
optionID=3 ;;
${options[3]} )
optionID=4 ;;
${options[4]} )
optionID=5 ;;
esac
if [ $optionID = 0 ]; then
goAhead=false
else
pickID=$(($optionID - 1))
KSPpath=$response
# KSPpath=$prePath${Kpaths[$(($optionID - 1))]}
echo "using path '$KSPpath'"
echo ""
echo "--> Wich application you wish to run?"
optionID=0
options[0]="run '$KSPapp$kspParams'"
options[1]="run mono 'ckan.exe'"
response=$( zenity --title="[:: KSP Launcher | run application ::]" --width=600 --height=250 --list --radiolist --text="$info" \
--column="" --column="Wich application you wish to run?" TRUE "${options[0]}" FALSE "${options[1]}" )
case "$response" in
${options[0]} )
optionID=1 ;;
${options[1]} )
optionID=2 ;;
esac
fi
if [ $optionID = 0 ]; then
goAhead=false
else
case $optionID in
1 )
echo ""
echo "[:: starting KSP ::]"
echo ""
cd "$KSPpath"
echo 'running --> export LC_ALL=C'
export LC_ALL=C
echo 'running --> export LD_PRELOAD="libpthread.so.0 libGL.so.1"'
export LD_PRELOAD="libpthread.so.0 libGL.so.1"
echo 'running --> export __GL_THREADED_OPTIMIZATIONS=1'
export __GL_THREADED_OPTIMIZATIONS=1
echo "executing > $preRun./$KSPapp$kspParams &"
sleep 2s
$preRun./$KSPapp$kspParams &
echo ""
sleep 1s
kspPID=$(pidof "$KSPapp")
echo "$kspPID"
if [ -n "$kspPID" ]; then
echo "starting logger:"
echo "----------------"
tail -f "$KSPpath/KSP.log" &
while :
do
kspPID=$(pidof "$KSPapp")
if [ -n "$kspPID" ]; then
sleep 1s
else
echo "$KSPapp has closed"
break
fi
done
fi
cd ;;
2 )
echo ""
echo "[:: starting ckan.exe (Mono) ::]"
cd "$KSPpath" && mono 'ckan.exe' && cd ;;
esac
fi
if [ $goAhead = false ]; then
echo "You've cancelled starting-up."
zenity --info --text="You've cancelled starting-up."
fi
echo ""
echo "done. :)"
sleep 5s
exit 0