Add path flag support

- add `-P` flag to manually set Spotify path
- add support for enabling write permissions in Spotify directory if write permissions are not found (thanks to @dabiathenord for the heads up)
- update readme for path flag and to note that Snap installs are not supported
This commit is contained in:
jetfir3 2022-10-24 13:07:23 -04:00 committed by GitHub
parent e9c1f77e2b
commit 3ff46a558d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 29 deletions

View File

@ -26,6 +26,7 @@
### Installation/Update:
NOTE: SpotX does not support the Spotify client from Snap
- Close Spotify completely.
- Run The following command in Terminal:
@ -37,6 +38,7 @@ bash <(curl -sSL https://raw.githubusercontent.com/SpotX-CLI/SpotX-Linux/main/in
`-c` Clear app cache -- use if UI-related patches aren't working
`-e` Experimental features -- enables experimental features
`-f` Force patch -- forces re-patching if backup detected
`-P` Path directory -- manually set Spotify directory if not found in PATH
`-p` Premium subscription setup -- use if premium subscriber
Use any combination of flags.

View File

@ -5,9 +5,32 @@ command -v perl >/dev/null || { echo -e "\nperl was not found, exiting...\n" >&2
command -v unzip >/dev/null || { echo -e "\nunzip was not found, exiting...\n" >&2; exit 1; }
command -v zip >/dev/null || { echo -e "\nzip was not found, exiting...\n" >&2; exit 1; }
# Inital paths and filenames
# Script flags
CACHE_FLAG='false'
EXPERIMENTAL_FLAG='false'
FORCE_FLAG='false'
PATH_FLAG=''
PREMIUM_FLAG='false'
while getopts 'cefP:p' flag; do
case "${flag}" in
c) CACHE_FLAG='true' ;;
e) EXPERIMENTAL_FLAG='true' ;;
f) FORCE_FLAG='true' ;;
P)
PATH_FLAG="${OPTARG}"
INSTALL_PATH="${PATH_FLAG}" ;;
p) PREMIUM_FLAG='true' ;;
*)
echo "Error: ${flag} not supported."
exit ;;
esac
done
# path vars
if [ -z ${INSTALL_PATH+x} ]; then
INSTALL_PATH=$(readlink -e `type -p spotify` 2>/dev/null | rev | cut -d/ -f2- | rev); fi
CACHE_PATH="${HOME}/.cache/spotify/"
INSTALL_PATH=$(readlink -e `type -p spotify` | rev | cut -d/ -f2- | rev)
XPUI_PATH="${INSTALL_PATH}/Apps"
XPUI_DIR="${XPUI_PATH}/xpui"
XPUI_BAK="${XPUI_PATH}/xpui.bak"
@ -17,33 +40,6 @@ XPUI_CSS="${XPUI_DIR}/xpui.css"
HOME_V2_JS="${XPUI_DIR}/home-v2.js"
VENDOR_XPUI_JS="${XPUI_DIR}/vendor~xpui.js"
# Detect client in PATH
if [[ ! -d "${INSTALL_PATH}" ]]; then
echo -e "\nSpotify not found in PATH. Exiting...\n"
exit; fi
# Script flags
CACHE_FLAG='false'
EXPERIMENTAL_FLAG='false'
FORCE_FLAG='false'
PREMIUM_FLAG='false'
while getopts 'cefp' flag; do
case "${flag}" in
c)
CACHE_FLAG='true' ;;
e)
EXPERIMENTAL_FLAG='true' ;;
f)
FORCE_FLAG='true' ;;
p)
PREMIUM_FLAG='true' ;;
*)
echo "Error: Flag not supported."
exit ;;
esac
done
# Perl command
PERL="perl -pi -w -e"
@ -98,11 +94,19 @@ echo "SpotX-Linux by @SpotX-CLI"
echo "**************************"
echo
# Detect client in PATH
if [[ ! -d "${INSTALL_PATH}" ]]; then
echo -e "\nSpotify path not found.\nSet directory path with -P flag.\nExiting...\n"
exit; fi
# xpui detection
if [[ ! -f "${XPUI_SPA}" ]]; then
echo - e "\nxpui not found!\nReinstall Spotify then try again.\nExiting...\n"
exit
else
if [[ ! -w "${XPUI_PATH}" ]]; then
echo -e "\nSpotX does not have write permission in Spotify directory.\nRequesting sudo permission...\n"
sudo chmod a+wr "${INSTALL_PATH}" && sudo chmod a+wr -R "${XPUI_PATH}"; fi
if [[ "${FORCE_FLAG}" == "false" ]]; then
if [[ -f "${XPUI_BAK}" ]]; then
echo "SpotX backup found, SpotX has already been used on this install."