I couple of months ago I bought a Sonos Play:1, a pretty cool wireless speaker that comes with free controller apps for major platforms (Android, Windows etc.). To give the speaker access to my music collection, I hooked up a USB drive to my home router and shared the music via SMB, which works great.
Unfortunately, I don’t always have an Android device handy when I’m at my Linux computer, so I thought it would be really useful to have a simple command line application to control the speaker. Since the device can be remote-controlled via UPnP, I decided to write my own client. Thanks to the SoCo Python library (install via
pip install soco), this was extremely easy to do.
Here’s the script that I came up with, tested with SoCo 0.6. I still manage the play queue using the Android app, but when I’m at my Linux computer I use the command line client to play, pause, control the volume, or skip tracks.