From 3985e55ae445fb67d3e54a5aadf8bcb9085feb99 Mon Sep 17 00:00:00 2001 From: rope Date: Fri, 14 Aug 2026 20:14:32 +0100 Subject: [PATCH] spotify-player: widen startup device-connect retry window Co-Authored-By: Claude Opus 5 --- home-manager/fred.nix | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/home-manager/fred.nix b/home-manager/fred.nix index ba3ebe8..4fc491c 100644 --- a/home-manager/fred.nix +++ b/home-manager/fred.nix @@ -74,24 +74,20 @@ in inherit src; hash = "sha256-CSZ5sZ+d7Jhi43ipaWXKupYPFgWCbCx4RMTQN8emu9o="; }; - # Always claim playback on our own device at launch, instead of having to - # pick it from the device popup every time. Two upstream guards in - # client/mod.rs stop that from happening: - # 1. initialize_playback skips connecting entirely if any playback - # already exists — a phone or web player holding a paused playback - # is enough. - # 2. find_available_device returns the currently *active* device before - # it ever gets to the "prefer the integrated device" branch. - # Disabling both leaves the integrated device as the startup target. - # The CLI can't do this from the outside: `connect --name` resolves names - # against the Web API device list, which usually doesn't contain our - # freshly registered librespot device at all. + # Give initialize_playback's retry loop a much longer window, so we don't + # have to pick our own device from the popup on every launch. Upstream + # retries the transfer 5 times, once a second; our librespot device isn't + # registered with the Spotify backend until ~20s after startup, so all + # five attempts 404 and it gives up: + # Trying to connect to device (id=…) + # Connection failed (device_id=…): http error: status code 404 Not Found + # The loop breaks on the first success, so a bigger bound costs nothing. + # The CLI is no help here: `connect --name` resolves names against the Web + # API device list, which doesn't contain the integrated device at all. postPatch = (old.postPatch or "") + '' substituteInPlace spotify_player/src/client/mod.rs \ - --replace-fail "if state.player.read().playback.is_some() {" \ - "if false {" \ - --replace-fail "if let Some(d) = devices.iter().find(|d| d.is_active) {" \ - "if let Some(d) = devices.iter().find(|d| false && d.is_active) {" + --replace-fail " for _ in 0..5 {" \ + " for _ in 0..60 {" ''; }); settings = {