[BUG] string comparation in :onscroll isn't working
antoniocorbi opened this issue · comments
Checklist before submitting an issue
- I have searched through the existing closed and open issues for eww and made sure this is not a duplicate
- I have specifically verified that this bug is not a common user error
- I am providing as much relevant information as I am able to in this bug report (Minimal config to reproduce the issue for example, if applicable)
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
Forgot to mention OS (nixos 23.11) and eww version: 0.4.0
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
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!