Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

Is there variables in waybar?

Open mubin-thinks opened this issue 1 year ago • 3 comments

Hi, recently, I was checking if style.css supports variables or not. And it turns out that it doesn't. Here is the code I've written to check it:

:root {
  --waybar-border-radius: 2;
}

waybar {
  background: #282828;
  border-radius: var(--waybar-border-radius)px solid black;
}

The following code didn't even launch waybar in the first place. You might ask when will you need it. Well, imagine this situation, you are writing a configurator and now, asking the user for a border radius they would prefer. How would you write it in css? If you don't have variables it would be hard to do. If you do though you can just prepend the following :root section.

I hope it's already added or it's simple to add. Thanks.

mubin-thinks avatar May 01 '24 13:05 mubin-thinks

Duplicate: https://github.com/Alexays/Waybar/issues/2112

zjeffer avatar May 01 '24 20:05 zjeffer

But I'm assigning border radius, not color.

mubin-thinks avatar May 02 '24 02:05 mubin-thinks

Ah, I see. In that case I'm not sure it's possible. What if you do @define-color waybar-border-radius 2;. Does that work?

zjeffer avatar May 02 '24 17:05 zjeffer

Ah, I see. In that case I'm not sure it's possible. What if you do @define-color waybar-border-radius 2;. Does that work?

Doesn't work for me

[2024-05-03 21:31:56.274] [error] style.css:11:38'1px' is not a valid color name

Edit: I use NixOS (home-manager-managed) so variables is as simple as using let..in bindings https://github.com/jfvillablanca/nixos-dot/blob/b74a1af7722e81a0bf40b348a4f501e9d5b40db6/homeModules/waybar/default.nix#L169C1-L191C51 but for a more native solution, I have no idea

jfvillablanca avatar May 03 '24 13:05 jfvillablanca

Why is this issue closed? It should be fixed.

mubin-thinks avatar May 06 '24 12:05 mubin-thinks