Add steam games directory sync
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
57
hosts/common/user/configs/gui/gaming/scripts/steam-ln.sh
Normal file
57
hosts/common/user/configs/gui/gaming/scripts/steam-ln.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
STEAM="${HOME}/.local/share/Steam/steamapps/common"
|
||||
GAMES="${HOME}/Games"
|
||||
|
||||
EXCLUDE=(
|
||||
"Proton - Experimental"
|
||||
"SteamLinuxRuntime_sniper"
|
||||
"Steamworks Shared"
|
||||
"Steam.dll"
|
||||
)
|
||||
|
||||
is_excluded() {
|
||||
local dir=$1
|
||||
for exclude in "${EXCLUDE[@]}"; do
|
||||
if [[ "${dir}" == "${exclude}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
for game in "${STEAM}"/*/; do
|
||||
name=$(basename "${game}")
|
||||
|
||||
if is_excluded "${name}"; then
|
||||
echo "Excluding ${name} from symlink creation."
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -L "${GAMES}/${name}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -d "${GAMES}/${name}" || -f "${GAMES}/${name}" ]]; then
|
||||
>&2 echo "Error: ${name} is already a regular directory or file."
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Creating symlink for ${name}..."
|
||||
ln -s "${game}" "${GAMES}/${name}"
|
||||
done
|
||||
|
||||
for link in "${GAMES}"/*; do
|
||||
target=$(readlink "${link}")
|
||||
|
||||
if [[ ! "${target}" == "${STEAM}/"* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
name=$(basename "${target}")
|
||||
|
||||
if [[ -e "${target}" ]] && ! is_excluded "${name}"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Removing symlink ${link}..."
|
||||
rm "${link}"
|
||||
done
|
Reference in New Issue
Block a user