I wanted a quick way to see the song playing on Spotify without switching apps. So, I built an Alfred workflow to handle it. The idea was simple: press a key, see the song info. To do this, you need Alfred's Powerpack—it’s the add-on that lets you create workflows. Here’s how it all came together.

Building the Workflow

  1. Create a Workflow: I opened Alfred Preferences (⌘ + ,) and went to the Workflows tab. I hit the + button, chose Blank Workflow, and named it “Spotify Now Playing.”
  2. Set a Keyword: I added a Keyword Trigger so I could run the workflow by typing spotify. Easy enough.
  1. Add a Script: The key part was an AppleScript to fetch the song info from Spotify. I added a Run Script action, set the language to osascript (AppleScript), and pasted this:
if application "Spotify" is running then
    tell application "Spotify"
        if player state is playing then
            set currentTrack to current track
            set songName to name of currentTrack
            set songArtist to artist of currentTrack
            set returnString to "\"" & songName & "\"" & " by " & "\"" & songArtist & "\""
            return returnString
        else
            return "Spotify is paused"
        end if
    end tell
else
    return "Spotify is not running"
end if
  1. Display the Result: To show the song info, I added a Post Notification output, setting the message to {query}—the result of the script.

Debugging the Problem

I ran it. Nothing happened. Frustrating, right? I opened Alfred’s Debugger to get a look under the hood:

Here’s what the log said:

[12:27:27.922] Keyword to Script to Notification[Keyword] Processing complete
[12:27:27.928] Keyword to Script to Notification[Keyword] Passing output '' to Run Script
[12:27:28.149] Keyword to Script to Notification[Run Script] Processing complete
[12:27:28.155] Keyword to Script to Notification[Run Script] Passing output '"Around The World - Radio Edit" by "Agrippa"' to Post Notification

The song info was there—clearly. But I wasn’t seeing any notifications. Turns out, my notifications for Alfred 5 were switched off. I fixed that, and the notifications started showing up.

A Simpler Approach

After a while, I realized I preferred something cleaner than a notification. So, I swapped the Post Notification for a Large Type output. Now, when I hit the keyword, the song info appears big and clear right in the middle of my screen.

No distractions, no fuss. Just the song, front and center. It’s exactly what I wanted.