altdesktop / playerctl

🎧 mpris media player command-line controller for vlc, mpv, RhythmBox, web browsers, cmus, mpd, spotify and others.
GNU Lesser General Public License v3.0
2.42k stars 79 forks source link

Idea: Provide interactive mode #188

Open gerion0 opened 3 years ago

gerion0 commented 3 years ago

I'm a user of mpv and Strawberry. Strawberry has a GUI while mpv has not, Strawberry is meant to controlled by a mouse while mpv is meant to control by a keyboard.

playerctl seems to bridge between both worlds since it provides a cli for (in my case) Strawberry. But the usage is other than in mpv, since playerctl is not interactive.

So, what do you think of an interactive mode for playerctl (maybe playerctl -i) so that it starts and remains started and accepts hotkeys like "Space" for pause, ">" for next, "<" for previous etc. (so its basically behaves like mpv)?

Of course this can be shellscripted quite easy with the help of playerctl but maybe you like the idea of a direct integration.

acrisci commented 3 years ago

Can it be done without adding any dependencies?

gerion0 commented 3 years ago

I'm not sure that I got the question right. What I mean with my request is basically a for loop. This is what it could look like from user perspective:

$ playerctl -i
Currently playing: Foo Bar from BarFoo
<-- Press space to pause, > for next and < for previous -->
You pressed space, pausing.
You pressed space, playing.
You pressed >, switching to next track.
Currently playing: A Song from A Singer
You pressed q, quiting.
$

In pseudo code it would be:

for (waiting_for_user_input() or waiting_for_mpris_event()) {
    if (new_user_input) {
        if (user_presses('space')) {
            pause_track();
        } else if (user_pressed('<')) {
            next_track();
        } ...
    } else if (new_mpris_event) {
        if (mpris_event == 'next song') {
            display_current_song();
        } ...
    }
}

So yes, this should be work without additional dependencies.

acrisci commented 3 years ago

I would accept an interactive mode into the project, but more details would need to be worked out for the features.

MarkusG commented 3 years ago

Got some boilerplate for interactivity down on my fork. Here are my thoughts on keybinds per command:

In addition, do we want to make these keybinds customizeable? Personally I think adding an entire configuration system just for keybinds is too much for a program like this.

gerion0 commented 3 years ago

Thanks for working on it. Here are a few thoughts of me:

Got some boilerplate for interactivity down on my fork. Here are my thoughts on keybinds per command:

  • play - maybe, might not be necessary with play-pause bound
  • pause - see above
  • play-pause - yes

Can all be merged in one command. I would suggest "Space" here as key. It's fairly common in several applications.

  • stop - yes
  • next - yes
  • previous - yes
  • position - yes; perhaps have vim-like seeking where the user can either use the arrow keys (or h/l) to move forward and back or type a sequence like 123g where 123 is an absolute position in seconds

I would orientate on other key based players. I only of mpv, mplayer and kodi. They support seeking in different ways:

I would prefer the mpv or mplayer way. The reason is, that in Kodi there is always a small delay since Kodi needs to wait for another keypress before it can seek.

  • volume - yes; see above
  • status - probably not, although we might as well; who knows, someone might want to pipe stdout to a file and update it whenever they hit a button ¯_(ツ)_/¯

mpv also has a status. I find it useful.

  • metadata - see above

This, too.

  • open - no; I don't see a feasible way to pass a URI with a single button keypress

Ok for me. One possibility for an "open" action is to send the url in the clipboard to the player with a single button.

  • loop - yes for setting (cycle through options); maybe for getting - see status and metadata
  • shuffle - see above

Ok for me.

In addition, do we want to make these keybinds customizeable? Personally I think adding an entire configuration system just for keybinds is too much for a program like this.

Hard coded keybindings are ok, IMHO.

I would very much prefer keybindings similar to existings programs. Here are the mpv keybindings, here the mplayer ones (naturally very similar) and here the ones of Kodi. Youtube also has some keyboard controls.