Alexays / Waybar

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

Icon doesn't update immediately on click unless "{}" is specified in format #1041

Closed 0xC0ncord closed 2 years ago

0xC0ncord commented 3 years ago

I have the following config in use:

"custom/screenlock": {
    "format": "{icon}",
    "format-icons": {
        "enabled": "",
        "disabled": "" 
    },
    "return-type": "json",
    "interval": 5,
    "exec": "~/.config/waybar/scripts/screenlock status",
    "on-click": "~/.config/waybar/scripts/screenlock toggle"
}

When the widget is clicked, the script kills/starts a background process and returns the status of it as alt depending on the state of the process. The icon of the widget should update immediately as soon as it is clicked (with respect to the interval it seems), but it does not. I discovered that if I set format to "{icon}{}" this works as expected, even if the script returns an empty string in text.

I expect the widget icon to update immediately even if no text is returned by the process started in on-click.

EDIT: It seems to be more wildly inconsistent than I originally thought. Sometimes it updates immediately, sometimes not. I have another widget with this exact configuration (yet using the text field) that does not have this issue.

g33kex commented 3 years ago

If exec-on-event is set to true, the exec command should always run after the on-click command so the script should update immediately.

However sometimes the exec command is run after the on-click command, and sometimes before. The module doesn't update correctly when the exec command is run before the on-click command.

According to the documentation:

If an event command is set (e.g. on-click or on-scroll-up) then re-execute the script after executing the event command.

So the exec command should always be executed after the on-click command, which is not currently the case. I think that might be what's causing this inconsistent behavior.