This Week's Sponsor:

Listen Later

Listen to Articles as Podcasts


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. ↩︎

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.