-
Notifications
You must be signed in to change notification settings - Fork 0
/
openmpt
executable file
·78 lines (63 loc) · 2.03 KB
/
openmpt
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
#!/bin/bash
# cs127's OpenMPT launch script for Linux
# version 0.5.0
# https://cs127.github.io
# Command line switches are the same as they are for the Windows executable,
# as seen in https://wiki.openmpt.org/Manual:_Command-line_Parameters
# but with two hyphens instead of a slash, and with hyphen-separated lowercase
# words instead of camelCase.
# Example: --no-assembly instead of /noAssembly
# Notes:
# The --shared argument has a short version -s,
# the --portable argument is ignored, since it can break things,
# and the --no-plugs and --no-dls arguments can also be written as
# --no-plugins and --no-soundfonts respectively.
files=()
args=""
# Set Wine options.
MPTDIR=/opt/openmpt
export WINEPREFIX=$HOME/.wine-openmpt
[ -z "$WINEDEBUG" ] && export WINEDEBUG=-all
# Detect if running as root.
if [ "$EUID" -eq 0 ]
then
echo "OpenMPT should not be run as root."
exit 64
fi
# Detect architecture.
if [ -z "$MPTARCH" ]
then
uname -m | grep '64' &>/dev/null && MPTARCH=64 || MPTARCH=32
elif [ "$MPTARCH" != "32" ] && [ "$MPTARCH" != "64" ]
then
echo "Invalid architecture '$MPTARCH'. Must be '32' or '64'."
exit 65
fi
# Handle short options (currently only -s).
if [[ $1 != --* ]]
then
while getopts "s" opt
do
case $opt in
s) args+="/shared " ;;
esac
done
fi
# Iterate through all arguments and parse them as options or files appropriately.
for arg in "$@"
do
if [[ "$arg" == --* ]]
then
[ "$arg" = "--no-plugins" ] && arg="--no-plugs"
[ "$arg" = "--no-soundfonts" ] && arg="--no-dls"
[ "$arg" != "--portable" ] && args+="$(echo "$arg" | sed -E -e 's/--/\//g' -e 's/-(.)/\U\1/g') "
elif [[ "$arg" != -* ]]
then
files+=("$(winepath -w "$arg")")
fi
done
# Configure Wine if the current user has never run OpenMPT.
! [ -f "$WINEPREFIX/user.reg" ] && wine regedit "$MPTDIR/wine_config.reg" &>/dev/null
# Launch OpenMPT.
[ "$MPTARCH" = "64" ] && MPTARCHDIR=amd64 || MPTARCHDIR=x86
wine $MPTDIR/bin/$MPTARCHDIR/OpenMPT.exe $args "${files[@]}"