spotify: start after keyring unlock, not at hyprland startup

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-08-23 19:37:40 +01:00
parent e9ab223891
commit 888eedad39
2 changed files with 31 additions and 6 deletions

View file

@ -328,11 +328,16 @@ in
hl.exec_cmd("wl-paste --type text --watch cliphist store") hl.exec_cmd("wl-paste --type text --watch cliphist store")
hl.exec_cmd("wl-paste --type image --watch cliphist store") hl.exec_cmd("wl-paste --type image --watch cliphist store")
hl.exec_cmd("hyprctl setcursor Bibata-Modern-Ice 24") hl.exec_cmd("hyprctl setcursor Bibata-Modern-Ice 24")
-- Spotify starts hidden: the window rule below swallows it onto -- Spotify is NOT started here. It asks the Secret Service for its
-- special:music silently, so it never steals focus and SUPER+M is -- credentials the moment it launches, which at this point is
-- always an instant toggle. -- before the lockscreen has been dismissed and therefore before
hl.exec_cmd(scratchpads["spotify"]) -- the login keyring is unlocked. Lock.qml unlocks the keyring with
-- Scratchpad terminal, same trick: parked on special:scratch at -- --replace, and that kills the daemon spotify would already be
-- mid-request with, leaving it stuck half-loaded. So Lock.qml
-- launches it instead, right after the unlock succeeds. The window
-- rule below still swallows it onto special:music, and the
-- respawn-on-close rule above is unaffected.
-- Scratchpad terminal: parked on special:scratch at
-- login so SUPER+Return is always an instant toggle and the shell -- login so SUPER+Return is always an instant toggle and the shell
-- keeps its history/cwd between peeks. -- keeps its history/cwd between peeks.
hl.exec_cmd(scratchpads["dev.fred.scratchpad"]) hl.exec_cmd(scratchpads["dev.fred.scratchpad"])

View file

@ -617,6 +617,9 @@ in
property alias locked: lock.locked property alias locked: lock.locked
property string password: "" property string password: ""
property bool failed: false property bool failed: false
// True only for the once-per-session lock below, so a later
// manual lock/unlock does not re-launch spotify.
property bool bootLock: false
function submit(pw) { function submit(pw) {
if (pam.active || pw === "") return; if (pam.active || pw === "") return;
@ -632,7 +635,7 @@ in
Process { Process {
running: true running: true
command: ["mkdir", Quickshell.env("XDG_RUNTIME_DIR") + "/qs-boot-lock"] command: ["mkdir", Quickshell.env("XDG_RUNTIME_DIR") + "/qs-boot-lock"]
onExited: code => { if (code === 0) lock.locked = true; } onExited: code => { if (code === 0) { root.bootLock = true; lock.locked = true; } }
} }
// Chromium/Electron apps ask the Secret Service for their // Chromium/Electron apps ask the Secret Service for their
@ -668,6 +671,23 @@ in
// EOF, or the daemon blocks on that read forever. // EOF, or the daemon blocks on that read forever.
stdinEnabled = false; stdinEnabled = false;
} }
// The Secret Service is up and unlocked by the time the
// parent exits (it forks, then exits 0 once the child
// signals ready). Only now is it safe to start spotify
// see the note in settings/hyprland.nix's startup handler
// for why it no longer autostarts there.
onExited: {
if (!root.bootLock) return;
root.bootLock = false;
spotifyStart.running = true;
}
}
Process {
id: spotifyStart
// Via hyprland, not as a child of quickshell: a shell
// restart on rebuild must not take spotify down with it.
command: ["hyprctl", "dispatch", "exec", "spotify"]
} }
PamContext { PamContext {