diff --git a/README.md b/README.md index 2807d91..2e605a1 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,11 @@ or ``` bash <(curl -sSL https://raw.githubusercontent.com/SpotX-Official/SpotX-Bash/main/spotx.sh) ``` +- If your shell does not support process substitution, use: +``` +curl -sSL https://spotx-official.github.io/run.sh | bash +``` +- See the [FAQ](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#why-does-the-recommended-command-fail-in-my-shell) for more information about shell compatibility and using options with the pipe command - By default... - all supported experimental features are enabled - free-tier user patches are applied, paid-premium users should use `-p` / `--premium` flag @@ -74,6 +79,7 @@ NixOS users should use [SpotX-Nix](https://github.com/SpotX-Official/SpotX-Nix), | `--installmac` | install latest supported client [macOS] | | `-l` | [set lyrics background color to black](https://github.com/SpotX-Official/SpotX-Bash/issues/20#issuecomment-1762040019) | | `--nocolor` | remove colors from SpotX-Bash output | +| `--noninteractive` | disable interactive prompts for automation | | `-o` | use [old home screen UI](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#what-is-the-old-and-new-ui) | | `-p` | [paid premium-tier subscriber](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#can-spotx-bash-be-used-with-a-paid-premium-account) | | `-P ` | set path to client | @@ -105,6 +111,10 @@ bash <(curl -sSL https://spotx-official.github.io/run.sh) --installdeb ``` bash <(curl -sSL https://spotx-official.github.io/run.sh) -B --installmac ``` +**Install latest supported client version without interactive prompts (macOS)** +``` +curl -sSL https://spotx-official.github.io/run.sh | bash -s -- --noninteractive --installmac +``` ### Thanks: diff --git a/spotx.sh b/spotx.sh index ba235da..4cbe8b2 100644 --- a/spotx.sh +++ b/spotx.sh @@ -35,6 +35,7 @@ show_help() { --installmac : install latest supported client version [macOS] -l, --lyricsbg : set lyrics background color to black --nocolor : remove colors from SpotX-Bash output +--noninteractive : disable interactive prompts -o, --oldui : use old home screen UI -p, --premium : paid premium-tier subscriber -P : set path to client @@ -100,10 +101,11 @@ while getopts ':BcdefF:hilopP:SvV:-:' flag; do hide) hideNonMusic='true' ;; installdeb) [[ "${platformType}" == "Linux" ]] && installDeb='true' ;; installmac) [[ "${platformType}" == "macOS" ]] && installMac='true' ;; - interactive) interactiveMode='true' ;; + interactive) interactiveMode='true'; interactiveRequested='true' ;; logo) logoVar='true' ;; lyricsbg) lyricsBg='true' ;; nocolor) unset clr green red yellow ;; + noninteractive) nonInteractive='true' ;; noexp) excludeExp='true' ;; oldui) oldUi='true' ;; premium) paidPremium='true' ;; @@ -122,7 +124,7 @@ while getopts ':BcdefF:hilopP:SvV:-:' flag; do f) forceSpotx='true' ;; F) forceVer="${OPTARG}"; clientVer="${forceVer}" ;; h) hideNonMusic='true' ;; - i) interactiveMode='true' ;; + i) interactiveMode='true'; interactiveRequested='true' ;; l) lyricsBg='true' ;; o) oldUi='true' ;; p) paidPremium='true' ;; @@ -135,6 +137,11 @@ while getopts ':BcdefF:hilopP:SvV:-:' flag; do esac done +[[ "${interactiveRequested}" && "${nonInteractive}" ]] && { + echo -e "${red}Error:${clr} '--interactive' and '--noninteractive' cannot be used together.\n" >&2 + exit 1 +} + gVer=$(echo "==QP9EkW0VzUS5kUVFlRKFDT1x2VZRXOplld41WW2dmMjhmSVxUWSNjY35UMMNnRXFmas1mWtlTVMllUzI2dOFDT0ljMZVXSXR2bShVYulTeMZTTINGMShUY" | rev | base64 --decode | base64 --decode) sxbLiveVer=$(printf "%s" \ "=0zdHJWM1IDTyY1RaZHNq10ZjNlZnNnaJhXUpl0ZR5mYwpESjd2cU10aBNFUnF1Va9m" \ @@ -722,10 +729,37 @@ perlvar() { } } +prepare_interactive_input() { + interactiveInput='none' + [[ "${nonInteractive}" ]] && { + [[ "${notInstalled}" && -z "${installMac}" && -z "${installDeb}" ]] && { + echo -e "\n${red}Error:${clr} Client not found and interactive setup is disabled.\n" >&2 + echo -e "Install Spotify first or use the appropriate '--installmac' or '--installdeb' option.\n" >&2 + return 1 + } + return 0 + } + [[ -t 0 ]] && { interactiveInput='stdin'; return 0; } + { : /dev/null && { + interactiveInput='tty' + return 0 + } + [[ "${interactiveRequested}" || ( "${notInstalled}" && -z "${installMac}" && -z "${installDeb}" ) ]] && { + echo -e "\n${red}Error:${clr} Interactive setup requires a terminal.\n" >&2 + echo -e "For automated environments, use '--noninteractive' with the required installation/options.\n" >&2 + return 1 + } + return 0 +} + read_yn() { local yn while : ; do - read -rp "$*" yn || { echo; return 1; } + case "${interactiveInput}" in + tty) read -r -p "$*" yn