Skip to content

Instantly share code, notes, and snippets.

@ssokolow
Created August 9, 2011 09:14
Show Gist options
  • Save ssokolow/1133645 to your computer and use it in GitHub Desktop.
Save ssokolow/1133645 to your computer and use it in GitHub Desktop.
XDG Basedir wrapper for Crayon Physics Deluxe
#/bin/sh
# XDG Base Directory Spec wrapper for Crayon Physics Deluxe as included in the
# Humble Indie Games Bundle 3
#
# Useful for hiding the non-hidden "Crayon Physics Deluxe" folder the game uses
# to store saved solutions
# Set this to where you installed Crayon Physics Deluxe
GAME_ROOT=~/opt/CrayonPhysicsDeluxe
# XDG Base Directory specification location for application data (eg. solutions)
# (Not ideal to have machine-specific config not separated into ~/.config but
# best I can do without fragile hacks or editing the game source)
HOME_ROOT=~/.local/share/crayonphysics
# If this is a first run, move data into place if necessary
if [ ! -e "$HOME_ROOT" ]; then
mkdir -p "$HOME_ROOT"
if [ -e ~/.CrayonPhysicsDeluxe ]; then
mv ~/.CrayonPhysicsDeluxe "$HOME_ROOT"
#Fixing paths in solution_manager.xml:
MANAGER="$HOME_ROOT/.CrayonPhysicsDeluxe/data/solution_manager.xml"
sed -i "s#$HOME#$HOME_ROOT#g" "$MANAGER"
fi
if [ -e ~/Crayon\ Physics\ Deluxe/ ]; then
mv ~/Crayon\ Physics\ Deluxe/ "$HOME_ROOT"
fi
fi
# The approach used here has the disadvantage, that directories like ".config"
# and ".fontconfig" will be created inside the fake home directory. A crude
# work-around for that would be to create symbolic backlinks for those folders.
export HOME="$HOME_ROOT"
cd "$GAME_ROOT"
exec ./launcher "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment