scripts/xdg-wrappers/steam

33 lines
855 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
#dep:steam
FAKEHOME=${XDG_DATA_HOME:-$HOME/.local/share}/steam
echo "Starting Steam in faked home $FAKEHOME" >&2
# Symlink a file to the fake home
link_dir() {
# Replace HOME with FAKEHOME in the link name
link_name=$(echo $1 | sed "s|^$HOME|$FAKEHOME|")
# Creates the link's parent directory and symlinks it
mkdir -p $(dirname $link_name)
if [ ! -d $link_name ]; then
echo "Linking $link_name" >&2
ln -s $1 $link_name
fi
}
mkdir -p $FAKEHOME
link_dir $XDG_DATA_HOME # ~/.local/share
link_dir $XDG_CACHE_HOME # ~/.cache
link_dir $XDG_CONFIG_HOME # ~/.config
# If .steam exists in ~/ and not in the fake home, move it to the fake home
if [ -d $HOME/.steam ] && [ ! -d $FAKEHOME/.steam ]; then
echo "migrating $HOME/.steam to $FAKEHOME" >&2
mv $HOME/.steam $FAKEHOME/
fi
export HOME=$FAKEHOME
exec /usr/bin/steam $@