Uh, long title, short explanation: I work primarily on an Ubuntu laptop but I listen to music from my Windows machine right next to it using foobar 2000, still the best mp3 player available (come at me bro!). On Windows I'm used to using foobar's global hotkey functionality to quickly pause and switch tracks, but on Ubuntu any way you try to pause or skip a track requires a context switch, which is damn annoying if you're in the programming zone. Here's how I solved it.
- Get the foobar http control plugin: https://code.google.com/p/foo-httpcontrol/
- Configure it to require a password just to be safe. Without it anyone can log in to your music player and mess up your playlist and what you're listening to. With the password on they can still do exactly that but they'll have to sniff the network packets, which really isn't worth it just to control a music player.
- Once configured, use the python script below to remote-control your foobar from the shell.
- In Ubuntu's hotkey configuration settings, add your hotkey and make it call the shell script you just created.
Here's the script:
import sys import requests from requests.auth import HTTPBasicAuth requests.get("http://your-ip-address-goes-here:1234/default?cmd=%s" % sys.argv, auth=HTTPBasicAuth('username', 'password'))
Voila! Cross-platform music hotkeys :D