I like to close the Spotify application on my phone and still listen to some background music. This is only possible with another device.
I run GitHub - Spotifyd/spotifyd: A spotify daemon
Let’s make a spotifyd.service.
Use superuser
instead of using the normal user we use superuser and put the contents in to /etc/systemd/system. it is workin good so far.
I don’t know why but sometimes I run a sudo cronjob to restart the job. I’ve removed the job on 2024-05-02.
Now (2024-08-19) I’ve noticed I want to have my alarm on my speakers.
there is currently a bug in spotifyd (actually upstream librespot) so I was using librespot-auth. Generate credentials.json and access it with librespot (using the directory with the credentials).
Best is Raspotify (or you have to use cargo to compile librespot yourself).
The best of it is that you can do credentials caching here.
To control it I use cargo built spotify_player from my server. Authentication is same as librespot (use the dircetory wtih the cerdentials.json with -C /path).
id of orangepi: e3a990a7cfec8e0c640b130e873bf705bbed6333
lets say I have a file: musicalarm.sh
There are interesting features of the cli. I use it to set the volume to 60% and play 10 of my liked songs in random order and then stop. Naturally it has spotify connect and I control it via the spotify app on other devices (mostly my phone).
We can add a cronjob: 0 8 * * 1-5 bash /home/musicalarm.sh to start the music every time to get up during the week.
To actually have the correct time we have to configure the timezone:
sudo timedatectl set-timezone Europe/Berlin.
Because we configured the small SBC on my stereo with a systemd service and the server to control the music with a cronjob it should automatically work after reboots and no further configuration is needed.