From 8b348d8c473b49a31a9a6d2e83ce10b1daea3802 Mon Sep 17 00:00:00 2001 From: rope Date: Sat, 15 Aug 2026 22:25:53 +0100 Subject: [PATCH] spotify-player: back to own client_id, cut per-action request burst Co-Authored-By: Claude Opus 5 --- home-manager/fred.nix | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/home-manager/fred.nix b/home-manager/fred.nix index 66f3de5..c933891 100644 --- a/home-manager/fred.nix +++ b/home-manager/fred.nix @@ -91,22 +91,43 @@ in # ~180 requests per launch into a shared rate-limit bucket (429s). 12 # rounds five seconds apart covers the same 60s for a fifth of the calls. # Both loops in this file are `for _ in 0..5` / `from_secs(1)`; the leading - # indentation is what pins each replacement to initialize_playback. + # indentation is what pins each replacement to the intended one. + # + # The third replacement hits the other loop, in retry_playback_state: it + # re-reads the playback state five times after *every* playback-changing + # action, so one flick of the volume wheel costs a write plus five reads + # per notch. The state is updated optimistically client-side anyway, so + # two confirmations are plenty. postPatch = (old.postPatch or "") + '' substituteInPlace spotify_player/src/client/mod.rs \ --replace-fail " for _ in 0..5 {" \ " for _ in 0..12 {" \ --replace-fail " let delay = std::time::Duration::from_secs(1);" \ - " let delay = std::time::Duration::from_secs(5);" + " let delay = std::time::Duration::from_secs(5);" \ + --replace-fail " for _ in 0..5 {" \ + " for _ in 0..2 {" ''; }); settings = { enable_audio_visualization = true; - # No `client_id` on purpose: the bundled default (ncspot's) has extended - # quota mode and predates the 2024-11-27 Web API changes. Our own app is - # newer, so it sits in the restricted quota and 404s on search, browse - # categories and Made-For-You — upstream issues #617 / #890. Sharing the - # default ID does not cost us rate limit here; upstream recommends it. + # Our own Spotify app rather than the bundled default (ncspot's client ID, + # shared by every spotify-player/ncspot install). Upstream recommends the + # default because it has extended quota mode, but its rate-limit bucket is + # shared across every user of it, and we hit 429s on it just adjusting the + # volume. Our own app gets a private bucket. + # + # The cost of a post-2024-11-27 app is restricted quota: Spotify returns + # its own editorial/algorithmic playlists as null, so Discover Weekly, + # Made-For-You and browse categories are missing. That used to break + # *search* outright (upstream #617/#621) because one null sank the whole + # deserialization, but rspotify 0.15.3 — pinned by 0.24.1 — drops null + # page items instead (`vec_without_nulls`), so search works again. + # Public PKCE client, no secret involved, so it's fine in the repo. + # Redirect URI registered: http://127.0.0.1:8989/login + client_id = "265506bc7bbd4032bf0fee708b321d3e"; + # Each notch fires a volume write plus a burst of confirmation polls, so + # halve the notches needed to cross the range. + volume_scroll_step = 10; }; # The home-manager module only writes keymap.toml when `keymaps` is # non-empty, so `actions` alone would silently emit nothing. Restating a