diff --git a/INSTALL.md b/INSTALL.md index 41d2211..6e0646d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -165,16 +165,16 @@ for Spotify offline support install [ClSpotify](https://github.com/agent255/clsp ``` printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt ``` -- copy [contrib/config/asound.conf](contrib/config/asound.conf) to `/etc/asound.conf`. +- copy [contrib/config/adafruit/asound.conf](contrib/config/adafruit/asound.conf) to `/etc/asound.conf`. ``` - cat /home/pi/luniebox/contrib/config/asound.conf | sudo tee /etc/asound.conf + cat /home/pi/luniebox/contrib/config/adafruit/asound.conf | sudo tee /etc/asound.conf ``` -- copy [contrib/config/.asoundrc](contrib/config/.asoundrc) to `/home/pi/.asoundrc`. +- copy [contrib/config/adafruit/.asoundrc](contrib/config/adafruit/.asoundrc) to `/home/pi/.asoundrc`. ``` - cat /home/pi/luniebox/contrib/config/.asoundrc | tee /home/pi/.asoundrc + cat /home/pi/luniebox/contrib/config/adafruit/.asoundrc | tee /home/pi/.asoundrc ``` diff --git a/application/daemon.py b/application/daemon.py index 7f748d0..89ca7b7 100644 --- a/application/daemon.py +++ b/application/daemon.py @@ -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__": diff --git a/application/luniebox.py b/application/luniebox.py index b48a53e..5b80287 100644 --- a/application/luniebox.py +++ b/application/luniebox.py @@ -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: diff --git a/contrib/config/.asoundrc b/contrib/config/adafruit/.asoundrc similarity index 100% rename from contrib/config/.asoundrc rename to contrib/config/adafruit/.asoundrc diff --git a/contrib/config/asound.conf b/contrib/config/adafruit/asound.conf similarity index 100% rename from contrib/config/asound.conf rename to contrib/config/adafruit/asound.conf diff --git a/luniebox.sh b/luniebox.sh index edfe6f7..a04d04f 100755 --- a/luniebox.sh +++ b/luniebox.sh @@ -434,8 +434,8 @@ setup_adafruit() { echo "Setup Adafruit Speaker Bonnet" sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt 1>/dev/null - cat /home/pi/luniebox/contrib/config/asound.conf | sudo tee /etc/asound.conf 1>/dev/null - cat /home/pi/luniebox/contrib/config/.asoundrc | tee /home/pi/.asoundrc 1>/dev/null + cat /home/pi/luniebox/contrib/config/adafruit/asound.conf | sudo tee /etc/asound.conf 1>/dev/null + cat /home/pi/luniebox/contrib/config/adafruit/.asoundrc | tee /home/pi/.asoundrc 1>/dev/null REBOOT=true echo "SETUP_AUDIO=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null }