Created
May 14, 2018 16:20
-
-
Save mds2/48d36404e9867ae9f5efa955f1f521a3 to your computer and use it in GitHub Desktop.
simple web interface to systemd music player
This file contains 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
[Unit] | |
Description=Dronezone (somafm) music player | |
Conflicts=sonic-universe.service groove-salad.service silence.service | |
[Service] | |
Type=simple | |
WorkingDirectory=/home/pi | |
ExecStart=/usr/bin/mplayer http://ice3.somafm.com/dronezone-128-mp3 | |
KillMode=process | |
Restart=on-failure | |
[Install] | |
Alias=dronezone.service |
This file contains 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, template | |
from subprocess import call | |
default_str = """<html> | |
<head><title>Music player</title></head> | |
<body> | |
<style> | |
li { | |
font-size:100px | |
} | |
</style> | |
<ul> | |
<li><a href="jazz">jazz</a></li> | |
<li><a href="drone">drone</a></li> | |
<li><a href="groove">groove</a></li> | |
<li><a href="silence">silence</a></li> | |
</ul> | |
</body> | |
</html>""" | |
@route('/play/<name>') | |
def play(name): | |
if name == "jazz": | |
call(["systemctl", "--user", "start", "sonic-universe.service"]) | |
elif name == "drone": | |
call(["systemctl", "--user", "start", "dronezone.service"]) | |
elif name == "groove": | |
call(["systemctl", "--user", "start", "groove-salad.service"]) | |
elif name == "silence": | |
call(["systemctl", "--user", "start", "silence.service"]) | |
else: | |
call(["systemctl", "--user", "start", "do-nothing.service"]) | |
return default_str | |
run(host='192.168.1.141', port=8080, debug=True) |
Author
mds2
commented
May 14, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment