diff --git a/home/stormux/.local/.functions/game_install_functions.sh b/home/stormux/.local/.functions/game_install_functions.sh index f3534aa..40ef674 100755 --- a/home/stormux/.local/.functions/game_install_functions.sh +++ b/home/stormux/.local/.functions/game_install_functions.sh @@ -114,22 +114,52 @@ open_url() { GAME="$*" startx } -get_installer() { +wait_for_enter() { + local message="$1" + + printf '%s\n' "$message" + if [[ -r /dev/tty ]]; then + read -r < /dev/tty || true + else + read -r || true + fi +} + +collect_installer_file() { local installerName="$1" local sourceDir - if [[ -f "${cache}/${installerName}" ]]; then + for sourceDir in "${cache}" "${HOME}/Downloads" "${HOME}/Desktop"; do + [[ -d "$sourceDir" ]] || continue + find "$sourceDir" -maxdepth 1 -type f -name "$installerName" -exec mv -v {} "${cache}/" \; 2> /dev/null || true + done + + [[ -f "${cache}/${installerName}" ]] +} + +get_installer() { + local installerName="$1" + local downloadUrl="${2:-}" + local instructions + + if collect_installer_file "$installerName"; then return 0 fi - for sourceDir in "${HOME}/Downloads" "${HOME}/Desktop"; do - find "${sourceDir}" -type f -name "${installerName}" -exec mv -v {} "${cache}/" \; 2> /dev/null || true - done + if [[ -n "$downloadUrl" ]]; then + instructions="Opening game download page, press enter to continue. +When the download finishes, please close your browser window to continue. You can do this by pressing control+w." + speak "$instructions" 1 + wait_for_enter "Press enter to continue." + open_url "$downloadUrl" - if [[ ! -f "${cache}/${installerName}" ]]; then - ui_msgbox "Game Installer" "Game Installer" "Could not find ${installerName}. Manual download support is not implemented yet." - exit 1 + if collect_installer_file "$installerName"; then + return 0 + fi fi + + ui_msgbox "Game Installer" "Game Installer" "Could not find ${installerName}. Make sure the download completed and the file name is ${installerName}." + exit 1 } install_with_progress() {