Fix Spotify patch scripts for Spotify 1.3.4
All checks were successful
Check and mirror to GitHub / checks (push) Successful in 22s
Check and mirror to GitHub / github-mirror (push) Successful in 10s

A Portage update to 1.3.4 broke the patch flow, and the snapshot fix
produced a client that crashed at startup.

- Skip spicetify restore when a stock xpui.spa is present, because the
  backup comes from the old build, and delete the old unpacked directories
- Replace root-owned client files with user-owned copies so SpotX-Bash
  does not ask for sudo
- Match the 1.3.4 lazy app form in spicetify-snapshotfix, and copy the
  experimental features hook
This commit is contained in:
Fi3w0 2026-11-05 18:28:08 +01:00
parent c6addd29ef
commit c28992b601
3 changed files with 22 additions and 7 deletions

View file

@ -17,4 +17,5 @@ does not grant these permissions or install a Portage ACL hook.
If you choose to use it, install the snapshot helper into `~/.local/bin` and
run the patch script as your regular user. The snapshot fix is specific to
the captured Spotify/Spicetify versions and should be reviewed against future
versions rather than assumed to work unchanged.
versions rather than assumed to work unchanged. Last checked on Spotify 1.3.4
with Spicetify 2.46.4 and Marketplace 1.0.12.

View file

@ -1,9 +1,10 @@
#!/usr/bin/env python3
# Spotify 1.2.96 runs its UI from xpui-snapshot.js, but spicetify 2.45.1 injects
# the custom-app code (Marketplace) only into xpui-modules.js:
# SpotX inlines the V8 snapshot modules into xpui-snapshot.js, which overrides
# xpui-modules.js, the only file spicetify patches. Seen on 1.2.96 and 1.3.4:
# - Spicetify._renderNavLinks(...) top-bar buttons
# - spicetifyAppN=X.lazy(...) the app's page component
# - (0,y.jsx)(R,{path:"/app/*",...}) the app's route
# - e=Spicetify.expFeatureOverride(e); experimental feature overrides
# Copy each missing fragment into the snapshot after the same preceding code.
# Run after every `spicetify apply`. Idempotent.
import re, sys
@ -14,8 +15,9 @@ mod, snap = open(mod_path).read(), open(snap_path).read()
patterns = [
r",Spicetify\._renderNavLinks\(\[[^\]]*\], *(?:true|false)\)",
r",spicetifyApp\d+=\w+\.lazy\(\(\(\)=>\w+\.e\(\"spicetify-routes-[^\"]+\"\)\.then\(\w+\.bind\(\w+,\"spicetify-routes-[^\"]+\"\)\)\)\)",
r",spicetifyApp\d+=\w+\.lazy\(\(\(\)=>.{1,200}?\w+\.bind\(\w+,\"spicetify-routes-[^\"]+\"\)\)\)\)",
r",\(0,\w+\.jsx\)\([\w.]+,\{path:\"/[^\"]+/\*\",pathV6:\"/[^\"]+/\*\",element:\(0,\w+\.jsx\)\(spicetifyApp\d+,\{\}\)\}\)",
r"\w+=Spicetify\.expFeatureOverride\(\w+\);",
]
added = 0

View file

@ -18,8 +18,14 @@ pkill -TERM -x spotify 2>/dev/null || true
for _ in {1..40}; do pgrep -x spotify >/dev/null || break; sleep 0.25; done
pgrep -x spotify >/dev/null && { echo "Spotify is still running, close it and retry." >&2; exit 1; }
# Undo spicetify first, so xpui.spa is stock or SpotX-only again.
"$spicetify" restore >/dev/null 2>&1 || true
if [[ -f $client/Apps/xpui.spa ]]; then
# A Spotify update puts stock *.spa back but leaves the unowned dirs of the old
# spicetify apply. Spicetify's backup is from the old build too: never restore it.
rm -rf -- "$client/Apps/xpui" "$client/Apps/login"
else
# Undo spicetify first, so xpui.spa is stock or SpotX-only again.
"$spicetify" restore >/dev/null 2>&1 </dev/null || true
fi
# SpotX backups left over from an older Spotify build (Portage replaced the
# client but not the unowned *.bak files) must not be restored by --force.
@ -35,6 +41,12 @@ if [[ -e $bak || -e $xbak ]]; then
fi
fi
# SpotX asks for sudo on files you do not own, and an update leaves them
# root-owned. The directory ACL lets you swap them for copies you own.
for f in "$client/spotify" "$client/Apps/xpui.spa"; do
[[ -O $f ]] || { cp -p -- "$f" "$f.fiw" && mv -f -- "$f.fiw" "$f"; }
done
tmp=$(mktemp --tmpdir spotx.XXXXXXXX.sh)
trap 'rm -f -- "$tmp"' EXIT
curl --proto '=https' --tlsv1.2 -fsSL "$spotx_url" -o "$tmp"
@ -44,7 +56,7 @@ bash "$tmp" -f -P "$client" "$@"
# Fresh spicetify backup of the SpotX-patched client, then apply.
"$spicetify" clear >/dev/null 2>&1 || true
"$spicetify" backup apply --no-restart
# spicetify 2.45.1 patches custom apps (Marketplace) into xpui-modules.js only
# spicetify patches custom apps (Marketplace) into xpui-modules.js only
"$HOME/.local/bin/spicetify-snapshotfix"
nohup spotify --enable-features=UseOzonePlatform --ozone-platform=wayland >/dev/null 2>&1 &