eww icon indicating copy to clipboard operation
eww copied to clipboard

[BUG] Variables are invalid in some cases after definition

Open jack9603301 opened this issue 2 years ago • 1 comments

Checklist before submitting an issue

  • [X] I have searched through the existing closed and open issues for eww and made sure this is not a duplicate
  • [X] I have specifically verified that this bug is not a common user error
  • [X] 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

In the following cases, current workspaces will not take effect. In order to solve this problem, label definition must be used.

(defpoll workspaces :interval "1s"
                    :initial "[]"
  "python ~/.config/eww/scripts/get-workspaces.py")

(defpoll current_workspace :interval "1s" :initial "1"
  "bash ~/.config/eww/scripts/get-current-workspace.sh")


(defwidget workspaces []
  (box :class "workspaces"
       :orientation "h"
       :space-evenly false
       :halign "start"
       :spacing 5
    (for workspace in workspaces
      (button :onclick "hyprctl dispatch workspace ${workspace.value}"
              :class "${workspace.id == current_workspace ? "current_workspace" : ""}"
        "${workspace.value}"))))

After startup, the current workspace cannot officially take effect unless the following configuration is added:

(label :text "${workspaces}${current_workspace}" :visible false)

Reproducing the issue

Just use the above configuration

Expected behaviour

The poll definition of current workspace should always start even without label! Because it may be referenced in the following judgments.

Additional context

Please read the description above

jack9603301 avatar Sep 12 '23 14:09 jack9603301

Hey, I could not reproduce the error of a poll not launching because there is no label. I tried the following:

(defpoll var :interval "1s"
                    :initial "0"
  "echo 1")

(defwindow button
  :monitor 0 
  (button :onclick "${var == 1 ? "eww close button" : ""}" "test"
	)
)

Also, to see whether the value updates:

(defpoll var :interval "1s"
                    :initial "0"
  "date +%S")

(defwindow button
  :monitor 0 
  (box
	(button :onclick "${var >= 30 ? "eww close button" : ""}" "test"
	)
  )
)

I also read the code that is launching inside of script_var_handlers.rs and polls are just launched no matter if they are used.

What happens if you try the examples I gave (didn't use your code because I don't have the get-workspaces.py)

luposmi avatar Sep 13 '23 19:09 luposmi