Controlling Web Based Music Players with Global Keyboard Shortcuts

Ever since I switched from iTunes to using web-based music players (Google Music, Amazon Cloud Player, and Pandora), I’ve wanted the ability to control them with global keyboard shortcuts. The other day, I finally took the time to set it up, and I’m very happy with the results:

If you’re interested in setting this up for yourself (or simply learning about how it works), download the project files here, then follow these instructions:

  1. Unzip the project files. You should see a directory called “music_control”.
  2. Make sure you have node.js installed, then cd into the “music_control” directory and start the server with: node server.js.
  3. Cd into the “extension” directory and open “background.html” in your favorite editor. Change the SERVER_HOST variable to reflect your host name.
  4. In Chrome, go to Window > Extensions. Make sure “Developer Mode” is checked.
  5. Click on “Load unpacked extension,” then navigate to the “extension” directory. (You can also package the extension and install it normally by double-clicking on the resulting “music_control.crx” file.)
  6. Install any application that lets you map global keyboard shortcuts to shell scripts (or AppleScripts, but I prefer bash). I used an app called Shortcuts, but I’m sure there are plenty of free alternatives.
  7. Setup whatever keyboard shortcuts you want to map to the following bash commands (note that you can use something like wget rather than curl if you prefer):
    • curl "http://localhost:8000/music?play"
    • curl "http://localhost:8000/music?next"
    • curl "http://localhost:8000/music?previous"
  8. You’re done! You should now be able to control you web-based music players with keyboard shortcuts.

I realize there are a lot of moving parts here, and any number of ways to accomplish the same thing. If you decide you don’t want to use this exact implementation, hopefully this will at least get you started down the right path of your own setup. Let me know if you get this working and/or if you adapt the concept to something equally or even more interesting. I have lots of ideas for where this could go.

Inspired by the Past

Not long ago, I took my two daughters out of school for the day and the three of us went on a field trip to Udvar-Hazy Air and Space Museum. I made a deal with them: they could miss school for the entire day if they promised to listen to everything I told them, read everything I asked them to read, and answer questions at the end of the day. I wasn’t taking them out of school to ride simulators and eat freeze-dried ice cream; we were going in search of inspiration.

The idea was prompted by the arrival of Discovery (which I also took them out of school to watch). I was about the age of my youngest daughter when the Space Shuttle Columbia first launched on April 12, 1981, and now, thirty-one years later, we were witnessing the (hopefully temporary) end of manned space flight in the United States. It suddenly occurred to me that without adequate education, children today might never know that:

  • Putting astronauts into low Earth orbit was once considered almost routine (the Space Shuttle fleet flew a total of 135 missions);
  • Forty-three years ago — more than four years before I was even born — man first walked on the moon, accomplishing a feat that doesn’t seem even remotely possible in today’s economic and political climate;
  • As children, we frequently saw the Concorde — a supersonic transport jet capable of traveling at over Mach 2 — fly overhead as it landed or took off from Dulles airport, conveying passengers from New York to Paris in only 3.5 hours — over twice as fast as brand new passenger jets being built today.

While I recognize that there’s a lot of fantastic innovation going on right now, we also appear to be in an era when the best way to inspire future generations is to look to the past.

discovery_1

The retired Space Shuttle Discovery.

discovery_2

The retired Space Shuttle Discovery.

discovery_3

The retired Space Shuttle Discovery.

concorde_1

The nose of the Concorde.

concorde_2

The unmistakable delta-wing configuration of the Concorde.

blackbird_1

The SR-71 Blackbird.

blackbird_2

Probably the best view in the entire museum. The SR-71 Blackbird in the foreground, and the Space Shuttle Discovery in the background.

blackbird_3

The top of the SR-71 Blackbird.

star_wars

Some of the toys that inspired me as a child.