Skip to content

Instantly share code, notes, and snippets.

@arnar
Created October 31, 2011 16:18
Show Gist options
  • Save arnar/1327872 to your computer and use it in GitHub Desktop.
Save arnar/1327872 to your computer and use it in GitHub Desktop.
Control Spotify from a bottle script
from bottle import route, run, debug
import subprocess
def sendkeys(*keys):
subprocess.call(['xdotool', 'search', '--name', 'Spotify Premium - Linux Preview', 'key'] + list(keys))
return "ok\n"
@route('/pause')
@route('/play')
def play(): return sendkeys('space')
@route('/next')
def next(): return sendkeys('ctrl+Right')
@route('/prev')
def prev(): return sendkeys('ctrl+Left')
debug(True)
run(host='', port=9000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment