mirror of
https://github.com/Felitendo/spotifast.git
synced 2026-11-01 17:33:26 +01:00
Fastpotify registers for the spotify: scheme on every platform, so a link shared from another app opens its page here, starting the app when it is not running and bringing the window forward when it is. A link is a positional argument, `fastpotify <link>`, which is what the desktop runs; src/link.rs turns every shape Spotify hands out (spotify: URIs, the old user-prefixed ones, open.spotify.com addresses with or without a locale and query) into the one canonical URI. A second launch hands the link to the running instance: over the control socket's new open-link verb on macOS and Windows, and on Linux through an Open method the single-instance guard now serves on its own bus name, from a thread with a runtime of its own since zbus registers an interface only inside one. An instance from before links never answers that call, so it is given two seconds and the window is raised instead. macOS delivers links as Apple Events, not arguments; a handler on NSAppleEventManager puts them on the same command queue. In the app, a link waits for the account to be signed in, then opens the page: a song's album and an episode's podcast, since neither has a page of its own, which needs one lookup first. Registration: %u on the desktop entry, CFBundleURLTypes in Info.plist, and the scheme plus a Default apps capability in the Windows installer, which on uninstall removes the shared scheme key only while it still names Fastpotify.