I need to run the following command after boot
arecord -f cd -t raw -D hw:1,0 -f S16_LE --buffer-size=1024 | aplay -f cd -t raw -D hifiberryMiniAmp -f S16_LE --buffer-size=1024
Basically it receives music from a usb DAC and plays it to the amplifier. I have modified asound.conf and it works nicely.
The problem is how it is best to run it continuously?
You could use crontab
for this or create an own systemd
unit
Thanks! Any pointers on how to create my own systemd unit on dietpi? Or is it just as any other systemd?
It’s like on every other Debian system.
You could also enter the command in rc.local as an autostart.
Until now I had the command in a /var/lib/dietpi/postboot.d/startmusic file and it just works. The problem is that sometimes it hangs and stops playing, especially after a long time (it plays 24x7). what I am doing is rebooting to start playing again.
I am trying to understand how could I have it as a service and ideally showing in the services webpage of the dashboard, so that I could simply login to the dashboard and restart the service. Is my approach correct?
First step would be to create the service unit. There are plenty of guides on the web how to do this for systemd