Rdio and Linux Part II

For whatever reason, my original rdio work-around (from this post) didn't work when I upgraded to Fedora 22. I'm sure it has something to do with the way Gnome 3.16 is handling window events, but I'm not spending the time to actually figure it out, because I've got a functiong work-around that is actually kind of cooler anyway.

I changed my .xbindkeys to this

"$(grep '^Exec' rdio.desktop | tail -1 | sed 's/^Exec=//' | sed 's/%.//')"
        Mod2 + XF86AudioMedia
"sleep 0.3 && ~/bin/mediacon play"
        Mod2 + XF86AudioPlay
"sleep 0.3 && ~/bin/mediacon prev"
        Mod2 + XF86AudioPrev
"sleep 0.3 && ~/bin/mediacon next"
        Mod2 + XF86AudioNext

All of the events have been moved into a script file that controls the actual events. This was done because I added a bit more logic to the events, and it was difficult to keep all that readable in the file. The other important thing to note is that all of the commands here are prefixed with a sleep. I had to do this because the events were firing too quickly and I had to slow that down just a tiny bit. I started with sleep 0.1, which worked when I used windowactivate in the script, but needed an additional time when I used windowfocus. I'm not really sure how the timing here differed when the commands in the script were called, but for whatever reason, this version is working.

The only other thing is my new mediacon script which is this:

CUR=$(xdotool getactivewindow)
xdotool windowfocus --sync $(xdotool search --limit 1 --name Rdio)
if [ $1 == "play" ]; then
        xdotool key space
elif [ $1 == "prev" ]; then
        xdotool key Left
elif [ $1 == "next" ]; then
        xdotool key Right
xdotool windowfocus $CUR

This is grabbing the id of the current window, activating the rdio window, sending whatever command you bound the key to, and then returning focus back to the window you started from.

Written by kellya in linux on 2015-05-21. Last modified: 2021-04-30 21:28:28.679853-04:00

Chat has been disabled for this post