Hi there, I hope this is the right spot to post this.
I have taken divVerent's updater and extended it (even beyond it's initial scope).
Now it is more like a full manager. you can choose to update or start the game(or just do both).
It has a very simple cmd argument parser(similar to ./all script syntax) and configurable default values, so that you normally don't need any arguments.
The script can disable compositing before the game starts and re-enable it when the game exits.
The script is able to find it's full path, so just put a symlink into your favorite bin folder or just click it to always run the latest version, no command line any more.
But I'm sorry: Linux/Mac(??, untested; Mac has bash, hasn't it?) only, as windows .bat syntax is just, well, limited...(and i can't code it
)
(In case someone is interested, I did something similar for OilRush game
[link to forum post])
I license this script under GNU GPL v2 or (at your opinion) any later version.
So feel free to use/adapt any part you like.(BTW: I mostly did copy n paste for the updater part, it almost stayed the same.)
download here, same as [ code ] below
[
attachment=460]
Code:
#!/bin/bash
## ===user config===
## those 2 settings are default actions which are chosen when the script is called without parameters
## just set them to whatever you find useful; look at the script's function print_help() below for a brief description, the parameters are the same
## possible default actions are "update", "start" and "update_start"
default_action="update_start"
## possible default builds are "sdl" and "glx"
default_build="sdl"
## [GENERALLY UNNEEDED] you do not need to set this! only use this, if you REALLY want to place the script somewhere else than the folder abve the Xonotic/Xonotic-high/Xonotic-low autobuild folder
## or if the autodetection fails (this should never happen(tm))
## just don't use it and everything is OK. If you want the script be in your $PATH, you can symlink the script into a bin directory eg. /usr/local/bin or ~/bin
#gamefolder="/usr/local/games/xonotic"
#gamefolder="$HOME/xonotic-autobuild"
## [LARGELY UNTESTED] This feature is still beta / work in progress / largely untested: It may cause system instabilities, data loss, or kills your cat and eats your hamster. You have been warned!
## Detect Window manager and compositing, if enabled
## uncomment the following line to probe for known compositing window managers
## and disable compositing while game is running; if it causes trouble, please post your used distribution, window manager and what exactly happens
#detect_wm_compositing="true"
## ===end of user config===
## ===script functions===
## detects the gamefolder
detect_gamefolder()
{
gamefolder="${BASH_SOURCE[0]}";
while [ -h "${gamefolder}" ]; do
gamefolder=`readlink "${gamefolder}"`
done
pushd . > /dev/null
cd `dirname ${gamefolder}` > /dev/null
gamefolder=`pwd`;
popd > /dev/null
}
## detects which xonotic version/build is installed
detect_xonotic()
{
if [ -d "$gamefolder/Xonotic-high" ]; then
echo "start_xonotic.sh: Xonotic-high found, using that"
xonotic=high
elif [ -d "$gamefolder/Xonotic" ]; then
echo "start_xonotic.sh: Xonotic found, using that"
xonotic=normal
elif [ -d "$gamefolder/Xonotic-low" ]; then
echo "start_xonotic.sh: Xonotic-low found, using that"
xonotic=low
else
echo "start_xonotic.sh: WARNING: nothing game-related found here. For the first start, this is normal."
xonotic=none
fi
}
## prints help
print_help()
{
echo "start_xonotic.sh: help"
echo "This script is intended to manage your Xonotic autobuild"
echo "usage:"
echo "\"start_xonotic.sh [mode] [binary]\""
echo "First parameter is neccessary for the second one, otherwise both are optional as"
echo "a default behaviour can be specified for both"
echo "mode can be:"
echo "\"start\": just starts the game; the script acts like a simple wrapper to start the game"
echo "\"update\": updates the game to the most recent autobuild; the script just behaves like update-xonotic.sh"
echo "\"update_start\":simply combines \"update\" and \"start\"; you always run the latest version, but it may take a long time until the game starts"
echo "\"help\": you read this help, so you already know this one ;)"
echo ""
echo "[binary] only works with the modes \"start\" and \"update_start\". It can be:"
echo "\"sdl\":starts the SDL binary; In fact, the script just calls xonotic-linux-sdl.sh inside your xonotic build"
echo "\"glx\":starts the GLX binary; Works just like the SDL parameter, but for the GLX binary"
}
## updates the game. works just like update-xonotic.sh
game_update()
{
if ! which rsync >/dev/null; then
echo >&2 "FATAL: rsync not found, please install the rsync package"
exit 1
fi
options="-Prtzil --executability --delete-after --delete-excluded --stats"
detect_xonotic
if [ "$xonotic" = "low" ]; then
url="rsync://beta.xonotic.org/autobuild-Xonotic-low/"
target="Xonotic-low/"
elif [ "$xonotic" = "high" ]; then
url="rsync://beta.xonotic.org/autobuild-Xonotic-high/"
target="Xonotic-high/"
else
url="rsync://beta.xonotic.org/autobuild-Xonotic/"
target="Xonotic/"
fi
unset excludes
excludes="$excludes --exclude=/*.exe"
excludes="$excludes --exclude=/fteqcc/*.exe"
excludes="$excludes --exclude=/bin32"
excludes="$excludes --exclude=/*.dll"
excludes="$excludes --exclude=/bin64"
case `uname`:`uname -m` in
Darwin:*)
excludes="$excludes --exclude=/xonotic-linux*"
excludes="$excludes --exclude=/fteqcc/fteqcc.linux*"
;;
Linux:x86_64)
excludes="$excludes --exclude=/Xonotic*.app"
excludes="$excludes --exclude=/xonotic-osx-*"
excludes="$excludes --exclude=/fteqcc/fteqcc.osx"
excludes="$excludes --exclude=/xonotic-linux32-*"
excludes="$excludes --exclude=/fteqcc/fteqcc.linux32"
;;
Linux:i?86)
excludes="$excludes --exclude=/Xonotic*.app"
excludes="$excludes --exclude=/xonotic-osx-*"
excludes="$excludes --exclude=/fteqcc/fteqcc.osx"
excludes="$excludes --exclude=/xonotic-linux64-*"
excludes="$excludes --exclude=/fteqcc/fteqcc.linux64"
;;
*)
echo >&2 "WARNING: Could not detect architecture - downloading all architectures"
;;
esac
rsync $options $excludes "$url" "$target"
}
## runs the game
game_run()
{
## detect and disable compositing(optional)
windowmanager="none"
compositing_state="false"
if [ "$detect_wm_compositing" = "true" ]; then
echo "start_xonotic.sh: probing for window managers with compositing support..."
## KDE
if [ "$(ps -C kwin)" ]; then
windowmanager="KWin"
echo "start_xonotic.sh: KDE KWin is running, checking for compositing state"
if [ "$(qdbus org.kde.kwin /KWin compositingActive)" = "true" ]; then
echo "start_xonotic.sh: Compositing state is active, disabling..."
compositing_state="true"
qdbus org.kde.kwin /KWin toggleCompositing
fi
## KDE isn't there, so lets probe for metacity: if it is there, the following condition will fail and the next probes will be done
elif [ -z "$(ls /usr/bin/metacity)" ]; then
echo "start_xonotic.sh: Metacity window manager seems not to be present on your system, so it can not be used to replace compositing window managers, skipping..."
## Compiz (mostly used with gnome or xfce)
elif [ "$(ps -C compiz)" ]; then
echo "start_xonotic.sh: Compiz is running, so compositing is enabled; replace it with metacity"
windowmanager="compiz"
compositing_state="true"
metacity --replace & > /dev/null
## Unity (Ubuntu)
elif [ "$(ps -C unity)" ]; then
echo "start_xonotic.sh: unity is running, so compositing is enabled; replace it with metacity"
windowmanager="unity"
compositing_state="true"
metacity --replace & > /dev/null
fi
echo "start_xonotic.sh: let the window manager start; wait 2 seconds..."
sleep 2
fi
detect_xonotic
if [ "$xonotic" = "high" ]; then
cd "Xonotic-high"
elif [ "$xonotic" = "normal" ]; then
cd "Xonotic"
elif [ "$xonotic" = "low" ]; then
cd "Xonotic-low"
else
echo "start_xonotic.sh: FATAL: ERROR in script function game_run( )"
echo "start_xonotic.sh: cannot start the game: game not found"
echo "start_xonotic.sh: use \"start_xonotic.sh update\" or \"start_xonotic.sh update_start\" to download the game data first"
exit 1
fi
##start the game
if [ "$1" = "sdl" ]; then
./xonotic-linux-sdl.sh
elif [ "$1" = "glx" ]; then
./xonotic-linux-glx.sh
else
## in case of wrong/no parameter use autodetection through top variable
if [ "$default_build" = "sdl" ]; then
./xonotic-linux-sdl.sh
else
./xonotic-linux-glx.sh
fi
fi
##restore compositing state
if [ "$compositing_state" = "true" ]; then
echo "start_xonotic.sh: game quit: Compositing was active, restore..."
if [ "$windowmanager" = "KWin" ]; then
echo "start_xonotic.sh: Re-enable KWin compositing"
qdbus org.kde.kwin /KWin toggleCompositing
fi
if [ "$windowmanager" = "compiz" ]; then
echo "start_xonotic.sh: Restart Compiz"
compiz --replace & > /dev/null
fi
if [ "$windowmanager" = "unity" ]; then
echo "start_xonotic.sh: Restart Unity"
unity --replace & > /dev/null
fi
fi
}
## ===end of script functions===
## ===script logic===
## if not set, detect and goto the gamefolder
if [ -z $gamefolder ]; then
detect_gamefolder
fi
cd "$gamefolder"
echo "start_xonotic.sh: Xonotic gamefolder is: \"$gamefolder\""
if [ "$1" ]; then
case "$1" in
"start")
if [ "$2" = "sdl" ]; then
echo "start_xonotic.sh: start the game using sdl"
game_run sdl
elif [ "$2" = "glx" ]; then
echo "start_xonotic.sh: start the game using glx"
game_run glx
else
echo "start_xonotic.sh: ERROR: unknown parameter for gamestart: \"$2\""
echo "start_xonotic.sh: FALLBACK: start the game using autostart values"
game_run
fi
;;
"update")
echo "start_xonotic.sh: update the game"
game_update
;;
"update_start")
echo "start_xonotic.sh: update the game"
game_update
if [ "$2" = "sdl" ]; then
echo "start_xonotic.sh: start the game using sdl"
game_run sdl
elif [ "$2" = "glx" ]; then
echo "start_xonotic.sh: start the game using glx"
game_run glx
else
echo "start_xonotic.sh: ERROR: unknown parameter for gamestart: \"$2\""
echo "start_xonotic.sh: FALLBACK: start the game using autostart values"
game_run
fi
;;
"help")
print_help
;;
*)
echo "start_xonotic.sh: enter \"start_xonotic.sh help for usage help\""
;;
esac
## check for default action to start
elif [ "$default_action" = "start" ]; then
echo "start_xonotic.sh: default action triggered: start the game"
game_run
elif [ "$default_action" = "update" ]; then
echo "start_xonotic.sh: default action triggered: update the game"
game_update
elif [ "$default_action" = "update_start" ]; then
echo "start_xonotic.sh: default action triggered: update the game and then run it"
game_update
game_run
else
echo "start_xonotic.sh: ERROR: I don't know what to do! No parameter entered and no default actions defined!"
exit 1
fi
## ===end of script logic===