summarylogtreecommitdiffstats
path: root/jquake.sh
blob: a46ae38d00fc081f8922f6940d03b10fce7229ef (plain)
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
#!/usr/bin/env bash
set -euo pipefail

# Define CLASSPATH
CP=""
for name in /usr/share/java/jquake/*.jar; do
  CP=$CP:$name
done
# Strip leading colon: an empty classpath entry means the current directory
CP="${CP#:}"

# The app stores its settings (Settings.properties) and errors.log
# in the working directory, so run from a persistent per-user directory
JDATA="${XDG_DATA_HOME:-$HOME/.local/share}/jquake"
mkdir -p "$JDATA"
cd "$JDATA"
# It also needs a ugly symlink for sounds
ln -sfn /usr/share/jquake/sounds sounds

# The app defaults its settings directory to the macOS path even on Linux,
# recorded in SettingsPath.properties: point it here instead, migrating any
# settings already saved to the macOS-style location
LEGACY="$HOME/Library/Application Support/JQuake"
if [ ! -e SettingsPath.properties ] || [ "$(cat SettingsPath.properties)" = "$LEGACY" ]; then
  if [ -d "$LEGACY" ]; then
    mv -n "$LEGACY"/*.properties "$JDATA/" 2>/dev/null || true
    rmdir "$LEGACY" "$HOME/Library/Application Support" "$HOME/Library" 2>/dev/null || true
  fi
  printf '%s' "$JDATA" > SettingsPath.properties
fi
exec /usr/bin/java -cp "$CP" -Xmx200m -Xms32m -Xmn2m -Djava.net.preferIPv4Stack=true -Dsun.sound.useNewAudioEngine="false" net.jquake.app.Main