Add loop for XDG CONFIG dir

This commit is contained in:
Jeremy Gardais 2019-10-10 22:46:35 +02:00
parent 1ac0f57da5
commit c0d544cc70
1 changed files with 31 additions and 1 deletions

View File

@ -26,7 +26,7 @@ debug=0
XDG_CONFIG_HOME="${HOME}/.config"
xdg_config="$(printf "%s" "${XDG_CONFIG_HOME}" | sed -e "s;${HOME}/;;")"
config_games="..."
xdg_config_games="..."
## }}}
## XDG data {{{
XDG_DATA_HOME="${HOME}/.local/share"
@ -105,3 +105,33 @@ done
## }}}
# }}}
# Manage XDG config save game {{{
for game_name in ${xdg_config_games}; do
local_game_path="${HOME}/${xdg_config}/${game_name}"
local_game_path_type="$(ls -ld "${local_game_path}" | sed 's/\(^.\).*/\1/')"
case ${local_game_path_type} in
## Data is already a symlink
"symbolic")
link_name="$(file "${local_game_path}" | sed 's;.* symbolic link to \(.*\);\1;')"
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: XDG CONFIG for loop — The data of ${game_name} are already symlinked to ${link_name} . Skip."
;;
## Data is still a directory
"directory")
move_game_dir "${game_name}" "${xdg_config}"
;;
## Data doesn't exist
"cannot")
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: XDG CONFIG for loop — The data of ${game_name} ${local_game_path} doesn't exist. Skip."
symlink_game_dir "${game_name}" "${xdg_config}"
;;
## Data can't be managed
*)
printf '\e[1;35m%-6s\e[m\n' "Data of ${game_name} (userdata) ${local_game_path} are not managed. Type: ${local_game_path_type}. Abort"
exit 3
;;
esac
done
# }}}