Last active
May 22, 2024 18:18
-
-
Save jetfir3/38a06194ec33583572fbac4f95ccc8df to your computer and use it in GitHub Desktop.
SpotX-Bash Updater (macOS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# The following script can run as a cron job to auto-update Spotify/SpotX-Bash | |
# Lines #6 and #7 can be customized to set Spotify.app location and SpotX-Bash arguments | |
appDir="/Applications/" | |
params="-Bd" | |
# Get macOS version | |
macOSVer=$(sw_vers -productVersion) | |
# Check if macOS version is less than 11 (Big Sur) | |
if [[ $(printf '%s\n' "10.16" "$macOSVer" | sort -V | head -n1) != "10.16" ]]; then | |
echo "macOS 11 or higher is required, exiting..." | |
exit 1 | |
fi | |
# Check if Spotify is installed | |
if [ ! -f "${appDir}/Spotify.app/Contents/MacOS/Spotify" ]; then | |
echo "Spotify not installed or not found in provided app directory path, exiting..." | |
exit 1 | |
fi | |
# Get currently installed client version | |
clientVer=$("${appDir}/Spotify.app/Contents/MacOS/Spotify" --version | perl -nle'print $& if m{(?<=Spotify version ).*?(?=\.g[0-9a-f]{8})}') | |
# Get latest SpotX-Bash version | |
spotxBashVer=$(bash <(curl -sSL https://spotx-official.github.io/run.sh) --version | perl -nle'print $& if m{(?<=SpotX-Bash version ).*}') | |
# Compare versions | |
if [ "$(printf '%s\n' "${clientVer}" "${spotxBashVer}" | sort -V | head -n1)" != "${spotxBashVer}" ]; then | |
# If SpotX-Bash version is higher, update and patch Spotify with SpotX-Bash | |
bash <(curl -sSL https://spotx-official.github.io/run.sh) -P "${appDir}" --installmac "${params}" | |
else | |
echo "No new SpotX-Bash version detected, exiting..." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment