spotify-player: patch startup to always claim our own device
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f34a9c9403
commit
649c153a65
1 changed files with 20 additions and 14 deletions
|
|
@ -74,6 +74,25 @@ in
|
||||||
inherit src;
|
inherit src;
|
||||||
hash = "sha256-CSZ5sZ+d7Jhi43ipaWXKupYPFgWCbCx4RMTQN8emu9o=";
|
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.
|
||||||
|
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) {"
|
||||||
|
'';
|
||||||
});
|
});
|
||||||
settings = {
|
settings = {
|
||||||
enable_audio_visualization = true;
|
enable_audio_visualization = true;
|
||||||
|
|
@ -88,23 +107,10 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
# Upstream ships no .desktop file (TUI only), so the launcher can't find it.
|
# 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 {
|
xdg.desktopEntries.spotify-player = lib.mkIf isDesktop {
|
||||||
name = "Spotify Player";
|
name = "Spotify Player";
|
||||||
genericName = "Music Player";
|
genericName = "Music Player";
|
||||||
exec = "ghostty --title=spotify-player -e ${pkgs.writeShellScript "spotify-player-connected" ''
|
exec = "ghostty --title=spotify-player -e spotify_player";
|
||||||
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";
|
icon = "spotify";
|
||||||
terminal = false;
|
terminal = false;
|
||||||
categories = [ "Audio" "Music" "Player" "AudioVideo" ];
|
categories = [ "Audio" "Music" "Player" "AudioVideo" ];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue