small fixes

This commit is contained in:
2022-02-24 16:12:47 +01:00
parent 04c89778f3
commit 5e98f8e873
6 changed files with 16 additions and 10 deletions
+8 -4
View File
@@ -109,6 +109,12 @@ class LunieboxDaemon(object):
luniebox.stop()
sys.exit(0)
def set_volume(self, volume):
volume_p = subprocess.Popen(
["amixer", "set", "PCM", volume + "%"], stdin=None,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
volume_p.wait()
def beep_sound(self):
self.play_sound("/home/pi/luniebox/audio/beep.wav",
str(self.luniebox.volume))
@@ -118,12 +124,10 @@ class LunieboxDaemon(object):
self.luniebox.get_setting('luniebox', 'error_volume', self.luniebox.volume_max)))
def play_sound(self, path, volume):
volume_p = subprocess.Popen(
["amixer", "set", "PCM", volume + "%"], stdin=None,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
volume_p.wait()
self.set_volume(volume)
subprocess.Popen(["aplay", path], stdin=None,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
self.set_volume(100)
if __name__ == "__main__":
+2
View File
@@ -9,6 +9,7 @@ import subprocess
import time
from enum import Enum
from configparser import ConfigParser
from turtle import update
import RPi.GPIO as GPIO
from spotifydl import SpotifyDL, SpotifyDLStatus
from mpd import MPDClient
@@ -369,6 +370,7 @@ class Luniebox(object):
def mpd_list(self, path=''):
if self.mpd_connect():
try:
self.mpd(update(path))
result = self.mpd.listfiles(path)
return sorted(result, key=self.sort_mpd)
except: