spotify-player: auto-connect to own device on launch

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-08-13 21:58:53 +01:00
parent 16f33c8dd7
commit 3e3e2df6f9

View file

@ -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" ];