noctuid / zscroll

A text scroller for panels or terminals
GNU General Public License v3.0
197 stars 10 forks source link

Support for multiple -M with -m #17

Open maplepy opened 2 years ago

maplepy commented 2 years ago

At the moment, when using multiple match-commands we get the message If there is more than one '-M', the number must match the number of '-m's. which is very confusing. Should we be using only one -m with -M if we have 2 -M ??

This doesn't make any sense to me....

I'd like to use something like that:

    --match-command "playerctl status" \
    --match-text "Playing"  "--after-text '   '" \
    --match-text "Paused"   "--after-text '   ' --scroll 0" \
    --match-command "playerctl metadata --format '{{playerName}}'" \
    --match-text "spotify"  "--before-text '阮  '" \
    --match-text "firefox"  "--before-text '  '" \
    --update-check true "playerctl metadata --format '{{ artist }} - {{ title }}'" &

but because -m is not following the previous -M it doesn't work

Could you add maybe argument to parse like-M "command_name" "command" to use with -m "command_name" "options" ?

That'd be very useful

noctuid commented 2 years ago

You can either have one command or a command for each --match-text. For you example, you wold have to do this:

--match-command "playerctl status" \
--match-text "Playing"  "--after-text '   '" \
--match-command "playerctl status" \
--match-text "Paused"   "--after-text '   ' --scroll 0"
...

Could you add maybe argument to parse like -M "command_name" "command" to use with -m "command_name" "options" ?

The current behavior is more verbose but good enough for your use case. I don't want to break backwards compatibility for these options. I would accept a PR for newly named options, but I don't plan on implementing this behavior myself.

maplepy commented 2 years ago

Well I’ll have to find another way then since having to repeat the same command for each player is going to get messy and annoying. Could I use a function for that ? Like -B "$prefix" ? 

noctuid commented 2 years ago

Yes, you could put the string in a variable:

status="playerctl status"
metadata="playerctl metadata --format '{{playerName}}'"

...

--match-command "$status" \
--match-text "Playing"  "--after-text '   '" \
--match-command "$status" \
--match-text "Paused"   "--after-text '   ' --scroll 0"
--match-command "$metadata" \
--match-text "spotify"  "--before-text '阮  '" \
--match-command "$metadata"
--match-text "firefox"  "--before-text '  '" \
...
maplepy commented 2 years ago

Ok nice! But if I wanted to have say two icons, both before the text, how could I do it? I have a function that outputs both say  

But I can't use it in the --before-text since it wants to print it right away, how can i put a function there (or at least a var) ?

maplepy commented 2 years ago

say I have prefix=" " and I want to have it in the --before-text, something like --before-text "$prefix". How can I use the var because doing it like that doesn't work

noctuid commented 2 years ago

How can I use the var because doing it like that doesn't work

What do you mean?

I don't really understand the question. You want to have a --before-text that changes based on some function? If that's what you're asking, it's not possible. Could you more specifically describe the condition where you want two icons printed and the full script you tried?

maplepy commented 2 years ago

I've managed to do what I wanted but that's by repeating the same thing over and over. At the moment zscroll doesn't support that, which is unfortunate. Having to repeat the same commands over and over makes the code ugly and harder to read but at least it's working.

What would be nice for the prefix and suffixes would be to use functions that echo/print commands instead of printing the text directly.

For example, you can use a command/script that prints the text by itself like it's done with

--update-check true "playerctl metadata --format '{{ artist }} - {{ title }}'" &

The playerctl function prints the text and zscroll just gets the outputs of said command and use it but that's not how it works for before and after-text which is weird and somewhat inconsistent with the other commands.

Say I wanted to use --before-text "playerctl metadata --format '{{ artist }}'",  it would not be able to print the output of the command but only print the text, in this case the command

------- Original Message -------

On Thursday, February 3rd, 2022 at 8:57 PM, Fox Kiester - notifications(a)github.com @.***> wrote:

How can I use the var because doing it like that doesn't work

What do you mean?

I don't really understand the question. You want to have a --before-text that changes based on some function? If that's what you're asking, it's not possible. Could you more specifically describe the condition where you want two icons printed and the full script you tried?

Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you authored the thread.Message ID: @.***>

maplepy commented 2 years ago

Could you more specifically describe the condition where you want two icons printed and the full script you tried?

At all times actually, I want to have the platform and the player status as prefixes, so spotify pause or youtube playing (but with icons)