Skip to content

Accessing selected song info from run_external_command #605

Open

Description

@sergueif

Is your feature request related to a problem? Please describe.
When executing either run_external_console_command or run_external_command, I'd like some access to the info about the track that the cursor is on, or the list of selected tracks. In other words, wanna be able to move around the various ncmpcpp screens (mostly main playlist), and press buttons to run external commands targeting things I selected in ncmpcpp.

There's a bunch of usecases that need this, but for a concrete example, I wanna make some scripts so that when i press 'S' in ncmpcpp, the selected track would be set to "liked" in another app I have (Navidrome). Similarly, i'd have a button for flagging tracks for certain other playlists, etc.

Describe the solution you'd like
I'd like to be able to do keybinds like this:

def_key "t"
 run_external_console_command "/path/to/myscript.sh $@"
 dummy 

def_key "y"
 run_external_command "/path/to/myotherscript.sh $@"
 dummy 

where $@ (or some other string) would expand into the path of the selected track (directory + filename, relative to "music_dir" of MPD perhaps). or maybe it could set and ENV variable for the external command like $SELETED_PATHS that contains the same info.

Describe alternatives you've considered
I know I can access the "currently playing" track in some way (via mpc), but that's not good enough for the above usecase. Sometimes I need to "target" the selected track, not one that's playing now. (i.e. maybe i'm looking at something that played a few tracks ago, etc.)

Additional context
fwiw, cmus music player does this for their :run command, where the {} expands into list of selected files. https://github.com/cmus/cmus/blob/d0a685d22ca510a911641044f3f7ff6f6b0cc6be/Doc/cmus.txt#L601

Also, a question: what exactly is the difference between run_external_command and run_external_console_command ? I didn't find a lot of explanation in the readme or the code.

Thank you for your attention.

Activity

  1. changed the title [-][FEATURE / QUESTION][/-] [+]Accessing selected song info from run_external_command/run_external_console_command[/+] on Aug 14, 2024
  2. changed the title [-]Accessing selected song info from run_external_command/run_external_console_command[/-] [+]Accessing selected song info from run_external_command[/+] on Aug 14, 2024
  3. pt321 commented on Aug 21, 2024

    @pt321

    Yes this would be useful in numerous ways like I keep a different database to hold the ratings of songs, with this I could easily pass the filepath of the song to the script that rates the song. Also to send songs to the Trash than permanently delete the song. It will also make group/classify/process songs.

    Or at least provide a way of getting the current selected song as the current song being played is not always going to be the same the one user has selected in the player.

  4. jwren0 commented on Oct 23, 2024

    @jwren0

    From a little experimentation, it seems like run_external_console_command handles commands which modify the contents of the terminal. Like, for example, other TUI programs.

    If you try to use a TUI program with run_external_command, when you return to ncmpcpp a lot of the UI will be missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions