Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions SuperIsland/Modules/NowPlaying/NowPlayingManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,11 @@ final class NowPlayingManager: ObservableObject {
}

nonisolated private func fetchSpotifyViaAppleScript() -> Bool {
// Don't compile any `tell application "Spotify"` AppleScript when
// Spotify isn't installed — doing so causes macOS to pop the
// "Where is Spotify?" Finder picker on every launch (issue #8).
guard isSpotifyInstalled() else { return false }

let script = """
tell application "System Events"
if not (exists process "Spotify") then return "NOT_RUNNING"
Expand Down Expand Up @@ -552,6 +557,8 @@ final class NowPlayingManager: ObservableObject {
}

nonisolated private func fetchSpotifyArtwork() {
guard isSpotifyInstalled() else { return }

let script = """
tell application "Spotify"
return artwork url of current track
Expand Down Expand Up @@ -1091,6 +1098,10 @@ final class NowPlayingManager: ObservableObject {
.replacingOccurrences(of: "\"", with: "\\\"")
}

nonisolated private func isSpotifyInstalled() -> Bool {
NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.spotify.client") != nil
}

private func isApplicationRunning(_ name: String) -> Bool {
NSWorkspace.shared.runningApplications.contains { app in
app.localizedName == name && !app.isTerminated
Expand Down
Loading