Created
October 31, 2011 16:18
-
-
Save arnar/1327872 to your computer and use it in GitHub Desktop.
Control Spotify from a bottle script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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