This Week's Sponsor:

Winterfest 2024

The Festival of Artisanal Software


Search For Rdio Lyrics with Keyboard Maestro

Macro

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.


  1. Usually the first link, because I’m lazy and I don’t want to scroll further down the page. ↩︎
  2. Chrome for Mac is kind enough to accept the search query even if it’s not been percent-encoded. ↩︎

Access Extra Content and Perks

Founded in 2015, Club MacStories has delivered exclusive content every week for nearly a decade.

What started with weekly and monthly email newsletters has blossomed into a family of memberships designed every MacStories fan.

Learn more here and from our Club FAQs.

Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with apps, tips, automation workflows, longform writing, early access to the MacStories Unwind podcast, periodic giveaways, and more;

Club MacStories+: Everything that Club MacStories offers, plus an active Discord community, advanced search and custom RSS features for exploring the Club’s entire back catalog, bonus columns, and dozens of app discounts;

Club Premier: All of the above and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.