Home alarm clock update – now with streaming audio

As mentioned in Home alarm clock update, I’d like to work with Snapcast.

Well, right off the bat, all the instructions for getting the Snapcast client to work automatically, did not. When I say “automatically” I mean that after I reboot the machine, I simply want the Snapcast client running without me having to do anything else. There were suggestions about making it a system service, and a user service, and none of those worked. I’m pretty sure it has something to do with my logged-in user having an environment which is different from what systemd or cron sees.

KAlarm to the rescue!

It has an option to launch stuff after reboot. That’s what I needed.

snapclient --host <IP address of MPD server goes here>

It does take a few seconds after reboot for KAlarm to figure out to run this command. But as soon as it does, my machine (whichever machine) taps into the stream, and music starts playing out. But because KAlarm doesn’t launch until after everything in KDE is up and running, I’m not having these weird errors where the Snapcast client cannot see the stream or the audio devices to play it out.

This is great.

However, what about my alarms? Those are music files too (well, sometimes a TTS wave file). The multiplexing nature of computer audio would have the two playing simultaneously. That is less than ideal.

Turns out that VLC has an option for exiting nicely after playing a file. Add a couple of MPC commands, and we’re golden. The magic command for VLC is rc --play-and-exit

I did have to install the MPC client (for controlling MPD servers) on my machines.

But now my KAlarm commands look like this:

mpc --host <IP address> pause
vlc --intf rc --play-and-exit /path/to/friday_morning.pls
mpc --host <IP address> play

I can queue up a whole stream of music files as background music, using Cantata, and when it comes time for my alarm to fire, to let me know it is time for the next event, the background music pauses through the whole house, the alarm does its thing, and then the background music resumes.

This is so neat. I am having fun with my computers again. 🙂

And I enjoy hearing the London Philharmonic Orchestra playing Sonic the Hedgehog: a Symphonic Suite and Elder Scrolls – Skyrim: Far Horizons. The Elder Scrolls V: Skyrim: Original Game Soundtrack has some great orchestral music. And now my whole house is filled with it.