Search For Rdio Lyrics with Keyboard Maestro

Macro

In spite of the existence of various Mac apps to display lyrics of a song that’s currently playing in iTunes or Rdio, I often find myself having to manually look them up through a web browser. It’s not uncommon to see a dedicated lyrics app being unable to fetch lyrics for a certain song, and, unsurprisingly, that always seems to happen when I’m in the mood for learning new lyrics. Having to Google lyrics and type a song’s name is a tedious process that ought to be automated, so that’s what I did.

I wanted to have a way to hit a single keyboard shortcut and be taken to a Google search page for a query such as “Incubus Anna Molly lyrics” (great song, by the way). I don’t have any particular preference for lyrics websites – I just know that they all share the same distaste for good web design – and therefore I don’t need to always search inside one specific website: I only need to fire up a Google search as quickly as possible, then click the link that better catches my attention.[1]

The solution I came up with uses Keyboard Maestro, but it can be used with other launchers and automation utilities as it’s entirely based on AppleScript; it’s also meant for Rdio, because that’s the service I use to listen to music on a daily basis.

Rdio for Mac is one of the few modern Mac apps to come with a decent AppleScript dictionary that also gets updated every once in a while; it’s easy to fetch information such as the name of current song or artist through AppleScript, so I’ve leveraged Keyboard Maestro’s “Execute AppleScript” action to get that information and save it to a variable.

tell application "Rdio"
set songname to get name of current track
set songartist to get artist of current track
set query to songname & " " & songartist & " lyrics"
end tell

The script simply concatenates the name of the song, artist, and the word “lyrics” on line 3, and Keyboard Maestro is told to save the output of the script into a variable called “SearchLyrics”. In the next action, Keyboard Maestro opens a new Google Chrome tab (part of version 6’s new browser actions) with a Google search URL that contains the variable as query.[2] The tab is opened by a keyboard shortcut, in a fraction of a second, in the background, and a native notification is displayed. I no longer have to manually type and launch a Google search whenever I feel like I should learn new lyrics to impress my friends.

As with last week’s Keyboard Maestro tip, I didn’t add checks for running applications and if/then statements. I’ll leave it up to you to be good Keyboard Maestro citizens and build a proper version. You can download the macro here.

Usually the first link, because I’m lazy and I don’t want to scroll further down the page. ↩

Chrome for Mac is kind enough to accept the search query even if it’s not been percent-encoded. ↩