eww icon indicating copy to clipboard operation
eww copied to clipboard

[FEATURE] Reference variables in the definition of other variables

Open TornaxO7 opened this issue 2 years ago • 2 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

I'd like to share the eww configs with two of my machines but each of them needs a little different setup (like size) so I'm trying to store some needed values in variabes which should be set during the startup of eww but somehow I can reuse some variables.

Reproducing the issue

Create ~/.config/eww/eww.yuck:

(defvar var true)
(defvar var2 {var ? 1 : 2})

(defwindow window []
  (label :text "hi"))

and execute eww open window. This should create the following error message:

error: Tried to reference variable `var`, but we cannot access variables here
  ┌─ /home/tornax/.config/eww/eww.yuck:2:15
  │
2 │ (defvar var2 {var ? 1 : 2})
  │               ───
  │
  → Expected format: `(defvar name "initial-value")`


Given SCSS File Doesnt Exist! /home/tornax/.config/eww/eww.scss

Caused by:
    No such file or directory (os error 2)

Expected behaviour

I expected to be able to use var in var2.

Additional context

No response

TornaxO7 avatar Aug 06 '22 16:08 TornaxO7

Currently, it's not possible to refer to variables in the definition of other variables. This may be possible in the future, so I'll keep this open, but for now this is expected behavior

elkowar avatar Aug 09 '22 10:08 elkowar

Oh, ok. Thank you for the information!

TornaxO7 avatar Aug 09 '22 10:08 TornaxO7

Just to make sure this would also apply to deflisten right?

use case

(defvar path "/some/pre/determined/path")
(deflisten listener "script --needed-config ${path}/the/file")

this is throwing the error "we cannot access variable here"

bfg-coding avatar Dec 14 '22 06:12 bfg-coding

bump

natto1784 avatar Jan 25 '23 15:01 natto1784

If possible it would be great if it would for windows as well (in addition to vars, polls, listens)

use case:

(defwindow bar1
  :monitor 1
  :windowtype "dock"
  :stacking "bg"
  :geometry (geometry :x "0%"
                      :y "0%"
                      ;; :width "100%"
                      :width "${1440 - trayer-width}"
                      :height "24px"
                      :anchor "top left")
  :reserve (struts :side "top"
                   :distance "24px")
  (centerbox :orientation "h"
             :class "bar"
             (leftside)
             ""
             (rightside-1)))

ArtemSmaznov avatar Mar 12 '23 18:03 ArtemSmaznov

Another use-case is on a multi-monitor setup to open the bar on the currently focused monitor (I use a keybinding to open/close the bar)

hvitoi avatar May 05 '23 01:05 hvitoi