elkowar / eww

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

[BUG] Listening variables not working correctly with for loop #922

Open horror-proton opened 11 months ago

horror-proton commented 11 months ago

Checklist before submitting an issue

Description of the bug

Listening variable not working in a for loop depending on another listening variable with empty initial or :initial "[]".

Reproducing the issue

Adding widget foo as following

(deflisten sec :initial "0" "sh -c 'while true; do sleep 1; date +%S; done'")
(deflisten bar :initial "[]" "echo '[1,2,3]'") ;
(defwidget foo []
  (box
    (for _ in "${bar}"
      (label :text "${sec}")
    )
  )
)

the text displayed on widget stays 0 0 0.

Expected behaviour

Text should be updated every second.

Additional context

Using eww 0.4.0 a9a35c1804d72ef92e04ee71555bd9e5a08fa17e


It works normally if :initial is not empty or another listening variable is in the box.

 (defwidget foo []
   (box
+    (label :text "${sec}")
     (for _ in "${bar}"
       (label :text "${sec}")
     )
   )
 )
acidkewpie commented 11 months ago

Playing with EWW for the first time today, this looks like there is no "needed_variables" relationship being defined for the as yet uninitialised variable inside the loop, so it is accessed before it is ready.

in-line with this I see no log entry for the "script_var_handler > starting listen-var "

Animeshz commented 9 months ago

Encountered bug here as well, when populating workspaces from EWMH.

Have you found a workaround?

acidkewpie commented 9 months ago

Encountered bug here as well, when populating workspaces from EWMH.

Have you found a workaround?

Personally I migrated to ags.

rice-cracker-dev commented 8 months ago

+1

J4ckTh3R1pper commented 7 months ago

encountered this bug as well, I personally use eww update in my script to update the variable