Skip to content

Instantly share code, notes, and snippets.

@wGEric wGEric/README.md forked from omailson/README.md
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.