Browse Source

Radio as system service

Robert Burghard 11 months ago
parent
commit
06b208db37
3 changed files with 17 additions and 1 deletions
  1. 1 0
      .gitignore
  2. 5 1
      bootstrap.py
  3. 11 0
      radio.service

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 .venv/
+__pycache__/

+ 5 - 1
bootstrap.py

@@ -2,11 +2,15 @@ import time
 from mpd import MPDClient
 
 
+time.sleep(10)
 client = MPDClient()
 client.timeout = 60
 client.connect("localhost", 6600)
 
 client.clear()
+client.setvol(50)
+client.repeat(1)
+client.single(1)
+
 client.load("internetradio")
-client.setvol(60)
 client.play(0)

+ 11 - 0
radio.service

@@ -0,0 +1,11 @@
+[Unit]
+Description=Internet Radio
+
+[Service]
+Restart=always
+User=robert
+WorkingDirectory=/home/robert/radio
+ExecStart=/bin/bash -c "source /home/robert/radio/.venv/bin/activate && sleep 20 && python3 /home/robert/radio/main.py"
+
+[Install]
+WantedBy=multi-user.target