Starting a playlist after boot

I am attempting to start a playlist after OSMC finishes booting on my Raspberry Pi 3B+

I have a script called
The script works if I call it by hand, and it writes to the log every time it boots, so SOMETHING is working.


now=$(date +"%Y %b %d %H:%M:%S")

echo "Stream Launched at $now" >> /home/osmc/scripts/logs/oofstream.log

/usr/bin/kodi-send --action=PlayerControl"(repeatall)"

/usr/bin/kodi-send --action=PlayerControl"(RandomOn)"

#kodi-send --action=PlayMedia"(/home/osmc/ooftv/broadcast/musicvideos , isdir)"

/usr/bin/kodi-send --action=PlayMedia"(/home/osmc/ooftv/broadcast/playlists/today.m3u)"

Here’s the contents of my /lib/systemd/system/mainplaylist.service

Description = Launch the main playlist at boot 
After = 
Type = oneshot
ExecStart = /home/osmc/scripts/
WantedBy =

So I know it’s running, but the videos never start playing. I’m thinking that the script is run too quickly, so the commands just get ignored. Any ideas what I’m doing wrong? Should I just put a delay in the shell script? That seems kind of sloppy so wondering if there was a better way to do it.

Just to confirm, adding

sleep 60 before the Kodi-send commands does the trick, so it seems like using systemd is too fast

Not to discourage your nice coding but you might just wanted to have used

Oh ha, yeah I guess I can try that instead. I thought that was out of date since it was still using xbmc

The python functions have not been renamed.

Although is a better way, you could also change your “mainplaylist.service” to add mediacenter.service to the “After” line.