hrkfdn / ncspot

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.
BSD 2-Clause "Simplified" License
4.89k stars 204 forks source link

FIFO pipe for player controls and playback status #97

Closed bashfulrobot closed 3 years ago

bashfulrobot commented 4 years ago

I was thinking about this... I have a repeatable pattern I do everymorning.

It would be interesting if you could launch ncspot with either cli paramaters or a cfg file to get to this same state. We could then autolaunch at startup.

If you allowed config/interactions via the CLI, it would allow custom keyboard shortcuts to a variety of states. Query the current song, etc. Potentially even easy integration to various linux desktop components.

:thinking:

Just an idea. It essentially becomes a spotify backend to many other potential interactions.

Completely ubnderstood if it is out of scope and what you see for the project.

hrkfdn commented 4 years ago

We could open up a FIFO pipe to which commands can be sent. Do you think this would be an option?

bashfulrobot commented 4 years ago

Tbh, I don't know rust enough to determine the best way to do this. If there is a better way to do it, and the docs can get a user going to accomplish the above, you are golden.

freijon commented 4 years ago

In mpv they have a JSON IPC. You could use a unix_socket::UnixListener (for Linux) and connect to it with a tool like socat and send commands with JSON or something similar. I did that in my app and it is a great way to communicate with an app IMHO. The most powerful feature would be an event system to which you could register. For example register to a is_paused property and send back a trigger when the property changed.

Just brainstorming ;)

Zocker1999NET commented 4 years ago

You could also implement a way like mpv has implemented the config file and parameters, so in the case of the author he would launch ncspot with the following parameters: --pause --shuffle https://open.spotify.com/user/<USER_NAME>/playlist/<PLAYLIST_ID> or --pause --shuffle --playlist <USER_NAME>/<PLAYLIST_ID>

bashfulrobot commented 4 years ago

You could also implement a way like mpv has implemented the config file and parameters, so in the case of the author he would launch ncspot with the following parameters: --pause --shuffle https://open.spotify.com/user/<USER_NAME>/playlist/<PLAYLIST_ID> or --pause --shuffle --playlist <USER_NAME>/<PLAYLIST_ID>

The option above would give a lot of flexibility as you could assign any combination to specific keyboard shortcuts, desktop file launchers, etc.

hrkfdn commented 3 years ago

I'd actually ditch this as most of this can be done via MPRIS now, e.g. playerctl can be used to control ncspot via MPRIS. Most desktop environments also support this.