From a2bdce01eb93f509efefc3907527134db9baec8c Mon Sep 17 00:00:00 2001 From: rope Date: Mon, 17 Aug 2026 09:42:28 +0100 Subject: [PATCH] hyprland: wait for DNS before starting spotify_player Co-Authored-By: Claude Opus 5 --- settings/hyprland.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/settings/hyprland.nix b/settings/hyprland.nix index 4c9fb94..0718d0e 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -276,7 +276,23 @@ in -- on them reads as "reset this thing", not "close it". local scratchpads = { ["dev.fred.scratchpad"] = "ghostty --class=dev.fred.scratchpad --title=scratchpad", - ["dev.fred.spotify"] = "ghostty --class=dev.fred.spotify --title=spotify-player -e spotify_player", + -- Waits for DNS before starting spotify_player. If its cached Web + -- API token cannot be refreshed it falls back to an interactive + -- browser login (auth.rs: the refresh `Err` arm re-runs the PKCE + -- flow), and a "network unreachable" refresh counts as failure — + -- so starting at hyprland.start, before the link is up, meant a + -- browser window and a fresh Spotify login on every single boot. + -- Costs nothing once the network is up, and also covers the + -- respawn path firing right after a resume. + ["dev.fred.spotify"] = "${pkgs.writeShellScript "spotify-player-scratchpad" '' + n=0 + while [ $n -lt 60 ]; do + ${pkgs.glibc.bin}/bin/getent hosts accounts.spotify.com >/dev/null 2>&1 && break + ${pkgs.coreutils}/bin/sleep 1 + n=$((n + 1)) + done + exec ghostty --class=dev.fred.spotify --title=spotify-player -e spotify_player + ''}", } local shutting_down = false hl.on("hyprland.shutdown", function() shutting_down = true end)