diff --git a/home-manager/fred.nix b/home-manager/fred.nix index df36402..f5fdb37 100644 --- a/home-manager/fred.nix +++ b/home-manager/fred.nix @@ -88,10 +88,23 @@ in }; # Upstream ships no .desktop file (TUI only), so the launcher can't find it. + # The launcher also force-connects to our own librespot device: upstream only + # auto-connects when *no* playback exists anywhere on the account + # (client/mod.rs `initialize_playback` bails out when playback.is_some()), so + # a phone or web player still holding a paused playback means we'd otherwise + # have to pick the device by hand every launch. Retry because the device takes + # a few seconds to register with Spotify. xdg.desktopEntries.spotify-player = lib.mkIf isDesktop { name = "Spotify Player"; genericName = "Music Player"; - exec = "ghostty --title=spotify-player -e spotify_player"; + exec = "ghostty --title=spotify-player -e ${pkgs.writeShellScript "spotify-player-connected" '' + sp=${config.programs.spotify-player.package}/bin/spotify_player + for _ in $(seq 15); do + sleep 2 + "$sp" connect --name spotify-player && break + done & + exec "$sp" + ''}"; icon = "spotify"; terminal = false; categories = [ "Audio" "Music" "Player" "AudioVideo" ];