diff --git a/docs/spotify.md b/docs/spotify.md index 86bdacb..5b89ded 100644 --- a/docs/spotify.md +++ b/docs/spotify.md @@ -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. diff --git a/optional/spotify/spicetify-snapshotfix b/optional/spotify/spicetify-snapshotfix index f17380c..d29121d 100755 --- a/optional/spotify/spicetify-snapshotfix +++ b/optional/spotify/spicetify-snapshotfix @@ -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 diff --git a/optional/spotify/spotify-patch b/optional/spotify/spotify-patch index 46b855f..0722be1 100755 --- a/optional/spotify/spotify-patch +++ b/optional/spotify/spotify-patch @@ -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 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 &