elkowar / eww

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

[FEATURE] Conditional Rendering of Widgets #709

Open sebastianrakel opened 1 year ago

sebastianrakel commented 1 year ago

Description of the requested feature

Hi,

i have a laptop and a workstation and they share the same bar. but my workstation does not have a battery. so there is currently following error in my configuration.

error: Failed to turn `` into a value of type json-value
   ┌─ /home/sebastian/.config/eww/eww.yuck:17:15
   │
17 │           :text {EWW_BATTERY["BAT1"].capacity + "%"} )))
   │                  ───────────

so my idea is an option/property which skips the rendering of the module. like an enable option/property.

Proposed configuration syntax

(label :enable false :text { EWW_BATTERY["BAT1"].capacity + "%" })

Additional context

No response

viandoxdev commented 1 year ago

see #517 (comments)

Also, take a look at the eww documentation.

sebastianrakel commented 1 year ago

Okay, i tested it with the visible property, but the widget is still processed and throws errors, cause there is no battery in this device

viandoxdev commented 1 year ago

You could try literal then, or use simplexpr features to avoid throwing errors (the recently merged json safe acess could work)

sebastianrakel commented 1 year ago

Will have a look into that, thanks!