Compare commits

...
2 Commits
Author SHA1 Message Date
jetfir3 b350dbe57d Add Nix build mode 2026-07-27 13:29:42 -04:00
jetfir3 38c1844f28 Improve flatpak detection and handling 2026-07-27 11:23:53 -04:00
+57 -14
View File
@@ -142,7 +142,7 @@ sxbLiveVer=$(printf "%s" \
"kcwwmW0V0VPRXQ6dlb1MEWyF1RYV3dxs0a4xGTjR3QaNWNDhlcRdEWvhTeKdWVtJGd" \
"BNkY5Z1Rjd2dIlUaw42YspVMadjUpl0Z3BzY0F0UjRXQDJWeWNTW" \
| rev | base64 --decode | base64 --decode)
sxbLive=$(eval "${sxbLiveVer}")
[[ "${SPOTX_BUILD_MODE}" ]] && sxbLive="${buildVer}" || sxbLive=$(eval "${sxbLiveVer}")
sxbVer=$(echo ${buildVer} | perl -ne '/(.*)\./ && print "$1"')
verCk=$(printf "%s" \
"9QzRYNGayMGaKdUZwkzRjpXODplb1k3YwJ0QRdWVHJWaGdkYwZUbkhmQ5NGcCNl" \
@@ -277,16 +277,18 @@ macos_prepare() {
}
linux_client_variant() {
[[ "${installPath}" == *"flatpak"* ]] && {
command -v flatpak >/dev/null && flatpak list | grep spotify >/dev/null && {
flatpakVer=$(LANG=C.UTF-8 flatpak info com.spotify.Client | grep Version: | perl -ne '/Version: (1\.[0-9]+\.[0-9]+\.[0-9]+)\.g[0-9a-f]+/ && print "$1"')
[[ -z "${flatpakVer+x}" ]] && versionFailed='true' || { clientVer="${flatpakVer}"; flatpakClient='true'; }
cachePath=$(timeout 10 find /var/lib/flatpak/ $HOME/.var/app -type d -path "*com.spotify.Client/cache/spotify*" -name "spotify" -print -quit 2>/dev/null)
[[ "${clientVariant}" == "flatpak" || "${installPath}" == *"flatpak"* ]] && {
command -v flatpak >/dev/null && flatpak info com.spotify.Client >/dev/null 2>&1 && {
flatpakVer=$(LC_ALL=C flatpak info com.spotify.Client 2>/dev/null | perl -ne '/Version: (1\.[0-9]+\.[0-9]+\.[0-9]+)\.g[0-9a-f]+/ && print "$1"')
[[ -z "${flatpakVer}" ]] && versionFailed='true' || { clientVer="${flatpakVer}"; flatpakClient='true'; }
cachePath="${HOME}/.var/app/com.spotify.Client/cache/spotify"
[[ -d "${cachePath}" ]] || unset cachePath
}
return 0
}
[[ "${installPath}" == *"opt/spotify"* || "${installPath}" == *"spotify-launcher"* || "${installPath}" == *"usr/share/spotify"* ]] && {
cachePath=$(timeout 10 find $HOME/.cache/ -type d -path "*.cache/spotify*" -not -path "*snap/spotify*" -name "spotify" -print -quit 2>/dev/null)
cachePath="${HOME}/.cache/spotify"
[[ -d "${cachePath}" ]] || unset cachePath
return 0
}
return 0
@@ -326,16 +328,56 @@ linux_no_client() {
exit 1
}
linux_resolve_client_path() {
local base="${1%/}" candidate
[[ -n "${base}" ]] || return 1
for candidate in \
"${base}" \
"${base}/extra/share/spotify" \
"${base}/share/spotify" \
"${base}/files/extra/share/spotify" \
"${base}/files/share/spotify"; do
[[ -f "${candidate}/Apps/xpui.spa" ]] && {
installPath="${candidate}"
return 0
}
done
return 1
}
linux_search_path() {
local paths=("/opt" "/usr/share" "/var/lib/flatpak" "$HOME/.local/share" "/")
local paths=("/opt" "/usr/share" "/usr/lib" "$HOME/.local/share" "/var/lib/flatpak/app/com.spotify.Client")
local flatpakPath spotifyBinary xpuiFile path
linux_resolve_client_path "/opt/spotify" && return 0
linux_resolve_client_path "/usr/share/spotify" && return 0
linux_resolve_client_path "$HOME/.local/share/spotify-launcher/install/usr/share/spotify" && return 0
spotifyBinary=$(command -v spotify 2>/dev/null)
[[ -n "${spotifyBinary}" ]] && {
spotifyBinary=$(readlink -f "${spotifyBinary}" 2>/dev/null || printf '%s' "${spotifyBinary}")
linux_resolve_client_path "${spotifyBinary%/*}" && return 0
}
command -v flatpak >/dev/null && {
flatpakPath=$(flatpak info --show-location com.spotify.Client 2>/dev/null)
[[ -n "${flatpakPath}" ]] && linux_resolve_client_path "${flatpakPath}" && {
clientVariant='flatpak'
return 0
}
}
for path in "${paths[@]}"; do
installPath=$(timeout 6 find "${path}" -type f -path "*/spotify*Apps/*" -not -path "*snapd/snap*" -not -path "*snap/spotify*" -not -path "*snap/bin*" -not -path "*flatpak/.removed*" -name "xpui.spa" -size -20M -size +3M -print -quit 2>/dev/null | rev | cut -d/ -f3- | rev)
[[ -n "${installPath}" ]] && return 0
[[ -d "${path}" ]] || continue
xpuiFile=$(timeout 6 find "${path}" \
\( -path "*/flatpak/.removed" -o -path "*/snap" -o -path "*/snapd/snap" \) -prune -o \
-type f -path "*/Apps/xpui.spa" -print -quit 2>/dev/null)
[[ -n "${xpuiFile}" ]] && {
installPath="${xpuiFile%/Apps/xpui.spa}"
return 0
}
done
return 1
}
linux_set_path() {
local requestedPath
[[ "${installDeb}" ]] && { linux_deb_prepare; return; }
[[ -z "${installPath+x}" ]] && {
echo -e "Searching for client directory...\n"
@@ -347,11 +389,13 @@ linux_set_path() {
} || linux_no_client
return
}
[[ "${installPath}" == *"snapd/snap"* || "${installPath}" == *"snap/spotify"* || "${installPath}" == *"snap/bin"* ]] && {
requestedPath="${installPath%/}"
[[ "${requestedPath}" == *"snapd/snap"* || "${requestedPath}" == *"snap/spotify"* || "${requestedPath}" == *"snap/bin"* ]] && {
echo -e "${red}Error:${clr} Snap client not supported. See FAQ for more info.\n" >&2
exit 1
}
[[ -f "${installPath}/Apps/xpui.spa" ]] && {
linux_resolve_client_path "${requestedPath}" && {
installOutput=$(echo "${installPath}" | perl -pe 's|^$ENV{HOME}|~|')
echo -e "Using client Directory: ${installOutput}\n"
linux_client_variant
} || {
@@ -368,7 +412,6 @@ linux_prepare() {
appBak="${appBinary}.bak"
snapshotBinary="${appPath}/v8_context_snapshot.bin"
xpuiPath="${appPath}/Apps"
[[ -z "${cachePath}" ]] && cachePath=$(timeout 10 find / -type d -path "*cache/spotify*" -not -path "*snap/spotify*" -name "spotify" -print -quit 2>/dev/null)
[[ "${debug}" ]] && echo -e "${green}Debug:${clr} $(cat /etc/*release | grep PRETTY_NAME | cut -d '"' -f2)"
[[ "${debug}" ]] && echo -e "${green}Debug:${clr} $(uname -m) detected"
[[ "${debug}" ]] && command -v apt >/dev/null && echo -e "${green}Debug:${clr} APT detected"
@@ -438,7 +481,7 @@ run_prepare() {
(($(ver "${clientVer}") > $(ver "${legacyMaxVer}"))) && macos_legacy_notice "toohigh"
client_version_output
ver_check
command pkill -9 '[sS]potify' 2>/dev/null
[[ -z "${SPOTX_BUILD_MODE}" ]] && command pkill -9 '[sS]potify' 2>/dev/null
[[ -f "${appBinary}" ]] && cleanAB=$(perl -ne '$found1 = 1 if /\x00\x73\x6C\x6F\x74\x73\x00/; $found2 = 1 if /\x2D\x70\x72\x65\x72\x6F\x6C\x6C/; END { print "true" if $found1 && $found2 }' "${appBinary}")
}