elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.4k stars 381 forks source link

[BUG] string comparation in :onscroll isn't working #1034

Closed antoniocorbi closed 7 months ago

antoniocorbi commented 8 months ago

Checklist before submitting an issue

Description of the bug

When implementing volume-up/down scrolling in a eventbox like this:

(eventbox
        :class       "eventbox"
        :onhover     "eww update volume=true"
        :onhoverlost "eww update volume=false"
        :cursor      "pointer"
        :onscroll    { "up" == {} ? "echo UP; amixer sset Master 5%+ >/dev/null" : "echo DOWN; amixer sset Master 5%- >/dev/null" }
        (box...

It always produces the 'else' string, but if implement :onscroll like this it works:

:onscroll    "if [ {} = \"up\" ]; then amixer sset Master 5%+ >/dev/null; else amixer sset Master 5%- >/dev/null; fi"

Reproducing the issue

No response

Expected behaviour

The first implementation proposed for :onscroll should work.

Additional context

No response

antoniocorbi commented 8 months ago

Forgot to mention OS (nixos 23.11) and eww version: 0.4.0

elkowar commented 8 months ago

Yeaa i see where the confusion is coming from - the issue here is that ewe evaluates the expression first, before replacing the {} with the "up" or "down" string, so whats actually happening is that youre comparing an empty json object to a string...

I don't think this will be avoidable any time soon, not before we get some form of lamdas

antoniocorbi commented 8 months ago

Thx Elkowar!

Yep, that's what I thought. Meanwhile I'm using something similar to the shell-script proposed.

Thanks for your work in eww!