Autostart simple alsaloop command

Having successfully used a pi with hifiberry amp hat as a synthesizer for my piano, taking midi in and creating sounds with fluidsynth,
I am now trying to simply use the same hardware as an amplifier. I have added a Behringer usb sound card for stereo sound capture
from the piano audio out.

In a bash shell I can simply use : alsaloop -C hw:CARD=CODEC,DEV=0 -P hw:CARD=sndrpihifiberry,DEV=0 &
which works fine.

If I put this into rc.local to run headless from boot, it needs a wait for usb to set-up, but even with an initial sleep I could not get this
to work.

I tried to use the option of the autostart script, with this command placed in /var/lib/dietpi/dietpi-autostart/. This starts and runs but stops
after some time (a few minutes) even if I add RuntimeMaxSec=infinity to the service (after some googling).

But if I simply order a reboot via shell, not only does it restart but never times out ??? How come ? I am on the v6.30 dietpi version.

Not so sure, tried again and it seemed to not time out… I will check a few times after the weekend…


as well you can create your own service file. I will link a small guide describing a couple of ways to run you stuff at startup. The service method is described on point 4: SYSTEMD

Have checked and still does not work for me.
I have tried various changes in the system service autostart, type, idle, simple, forking, infinite time, always restart…
but to no avail, After under 5 mins the command stops, but if I reboot it keeps active much longer.
My service is:
Description=DietPi-Autostart (Custom /var/lib/dietpi/dietpi-autostart/
After=dietpi-boot.service dietpi-postboot.service rc-local.service

ExecStartPre=/bin/chmod +x /var/lib/dietpi/dietpi-autostart/
ExecStartPre=/bin/echo ‘Starting DietPi-Autostart (Custom) script…’


and the is simply :
alsaloop -C hw:CARD=CODEC,DEV=0 -P hw:CARD=sndrpihifiberry,DEV=0 &
exit 0

I would appreciate comments on what is wrong… thanks

no need to call with your own service.You could call the command directly

ExecStart /full/path/to/alsaloop -C hw:CARD=CODEC,DEV=0 -P hw:CARD=sndrpihifiberry,DEV=0 &

pls use full patch to alsaloop

Thanks very much, that works !

I initially left my simple command in a separate script file to remain compatible with the autostart option during
dietpi-config in a clean install, which I felt would be easier to maintain.

So summary,

anyone who wants a single line command at start-up, and which remains always active,
better use this solution than a separate script file…


would it be possible to post your service file. Maybe it could help others

systemctl cat <your-name>.service