Part 5
Autostart PeppyMeter when a song is played
If you don’t want a picture slideshow to start when Peppy is not running adjust the code acordingly.
- To schedule PeppyMeter to run as a screen saver only when a song is played follow these steps
- Create a script and change its permissions to execute with sudo chmod 777 /home/volumio/PeppyMeter/screensaver.sh and insert this code:
#!/bin/bash
sleep 60
export HOME=/home/volumio/PeppyMeter
export DISPLAY=:0
while true; do
if volumio status | grep -q ': "play",'; then
# Playing
cd /home/volumio/PeppyMeter
python3 ./volumio_peppymeter.py
else
# Stopped
if ! pgrep -x "feh" >/dev/null; then
pidof python3 && pkill python3
fi
fi
sleep 11s
done
- Create a system unit file with sudo nano /lib/systemd/system/screensaver.service and enter the following code:
[Unit]
Description=My Shell Script
[Service]
ExecStart=/home/volumio/PeppyMeter/screensaver.sh
[Install]
WantedBy=multi-user.target
- Enable the new service with
- sudo systemctl daemon-reload
- sudo systemctl enable screensaver.service
- Start the service to test
- sudo systemctl start screensaver.service
- Check the status every 30 secs
- sudo systemctl status screensaver.service
- If everything works reboot and test to see if the service is running using the status command above.
NOTE: The application feh is probably not installed so you’ll have to install it by running sudo apt-get install feh
This is all I got. It works fine for me however peppy once in a while will crash and you’ll need to reboot volumio. Can’t ask for too much for free.
Enjoy. I hope it works for everyone. I’ll try to answer questions as much as I can.