What does that even mean? It means that this is how I like to search for music and listen to music on a Unix system. This is a spotify controller and does not (yet anyway) include a way to stream the actual music. But there's already a very good such player (which I use with Spotnix): https://github.com/spotifyd/spotifyd.
It's really really early days so there's likely to be some rough edges, missing features and scrappyness... however, I use it daily.
First, here's a taste of what a session might look like (spotnix on the left, on the right we search and select what to play):
So what's so special about this then? Well, you get three named pipes and that's it. What's not to like :-)? The standard names of those pipes:
./input
(eg. play something, pause, list devices, search etc.)
./output
(results of a search, results of list devices etc.)
./events
(really just playback status atm such as progress, track name etc).
sh
echo search_playlist electronic > ./input
To get the results and select something to play (you can ofc use https://github.com/junegunn/fzf as well, I like https://github.com/lotabout/skim - probably just because I'm biased as I'm very fond of the Rust programming language):
sh
cat ./output | sk | awk '{print $NF}' | xargs -r -I{} echo play {} > ./input
Or just all in one:
sh
echo search_playlist electronic > ./input; cat ./output | sk | awk '{print $NF}' | xargs -r -I{} echo play {} > ./input
To get playback status (eg. progress, name of song / album etc):
sh
cat ./event
(The above updates every 5 seconds as it is, until then your cat
will hang. Just cat
again or read that pipe in a loop or whatever you like for updates.)
Obviously you'd probably put all the above things in scripts - but it's up to you how you use it, these are just building blocks - the Unix way. For some basic example scripts, see: examples
The available commands at the moment are (those you send into the ./input pipe):
sh
play <optional spotify uri> (without uri - resume playback)
pause
shuffle true/false
search_track <search string>
search_album <search string>
search_artist <search string>
search_playlist <search string>
devices (list devices available)
device <device id> (selects the device use for playback)
next
prev
At the moment there's no packages so you'll have to build it. First, install Rust then
bash
cargo install spotnix
Personally I use Nix to manage dependencies, including the Rust toolchain, but I know Rustup is really good.
To update spotnix you can run
bash
cargo install spotnix --force
spotnix
talks to Spotify's Web API to do it's thing (eg. search, play, pause etc.).
When you start spotnix
the first time, you will be asked to login to spotify BUT - to really make it work, you must actually do a little bit more:
Create a Client ID
and create an appEdit Settings
http://localhost:8182/spotnix
to the Redirect URIsCLIENT_ID=abcde12345 CLIENT_SECRET=sasjfijs2983 REDIRECT_URI=http://localhost:8182/spotnix
This is currently the help output of spotnix:
```sh spotnix 0.1.0 spotify as a series of "tubes"... or rather named pipes.
USAGE: spotnix [OPTIONS]
FLAGS: -h, --help Prints help information -V, --version Prints version information
OPTIONS:
-e, --event
So that is Spotify for Unix - you get to use all those command line tools you know and love to find and listen to music!