Skip to content

Instantly share code, notes, and snippets.

@wGEric
Forked from omailson/README.md
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wGEric/9903874 to your computer and use it in GitHub Desktop.
Save wGEric/9903874 to your computer and use it in GitHub Desktop.
Linux, Rdio and media buttons

I like Rdio and linux. Rdio works great in a browser except for one thing: keyboard shortcuts!!!

When coding, I like to be able to play/pause my music quickly, meaning I don't want to switch windows. I figured out a way to do this:

Google Chrome App

First, I created a shortcut to the app from Google Chrome. Right click on the app and create the shortcut.

xdotool

Next, I made a file in my ~/bin called rdio.

This looks up a window with the name "Rdio" and sends the "space" key to it, which is Rdio's keyboard shortcut for play/pause. Left and right arrows are for next and previous.

xdotool needs to be installed.

sudo apt-get install xdotool

Window Manager Keyboard Shortcut

Last, I created keyboard shortcuts for the media keys to run the commands.

rdio play to play/pause rdio next to skip to next song rdio previous to go to previous song

Thanks

Thanks to @IAmAru for suggesting I look into window manager command line tools.

#!/bin/sh
case "$1" in
play|pause)
action="space"
;;
next)
action="Right"
;;
previous)
action="Left"
;;
*)
action="space"
;;
esac
player=$(xdotool search --name " – Rdio" | head -1)
[ -z $player ] && player=$(xdotool search --name "Google Play Music" | head -1)
xdotool key --window $player "$action"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment