Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
5.98k stars 671 forks source link

JSON output of command triggered by "exec-on-event" is ignored #2552

Open smurfix opened 9 months ago

smurfix commented 9 months ago

Assume this nice little module:

    "custom/dark": {
        "return-type": "json",
        "exec-on-event": true,
        "interval": 60,
        "on-click": "dark f",
        "exec": "darkmode i",
        "on-click": "darkmode f"
    }

The "darkmode" script emits this JSON snippet: {"text":"💡","tooltip":"it is light","class":["mode","light"]}

The problem is that the exec-on-event setting is summarily ignored. Or rather, the JSON returned by the program is ignored. My icon thus changes (up to) a minute after clicking it, which is not quite what I'd like to see.

Is there a way to fix that?

Druneau commented 9 months ago

I'm trying to do something similar and am hitting the same issue.

It works if I set an interval, but is not instant as expected when I trigger an "on-click" event.

Edit: I have exec-on-event working for me now. I had to set "interval": "once"; and now when I click the module through "on-click" it fires off "exec": "myscript".

VAWVAW commented 5 months ago

I solved the problem by adding a signal to the module and triggering the signal in the on-click.

juanolon commented 2 months ago

i had the same problem and funnily enough, i was also trying to update a dark/light mode module. I did also solve it with the signal approach