eww icon indicating copy to clipboard operation
eww copied to clipboard

[FEATURE] Add `calc()` to geometry's width property

Open fufexan opened this issue 3 years ago • 5 comments

Description of the requested feature

I'd like to be able to have my bar 100%-10px wide, but it seems like that's not possible. I've tried setting 99.5% but that also doesn't work.

Is there a way to set it how I want through different methods? If not, can it be implemented?

Proposed configuration syntax

(defwindow bar
  :monitor 0
  :geometry (geometry
    :x "0px"
    :y "0px"
    :width "calc(100%-10px)"
    :height "32px"
    :anchor "top center")
  :stacking "fg"
  :exclusive true
  (bar))

Additional context

Using eww in Hyprland with 99% width instead makes it look like this image

...which isn't as pleasing to look at as at a bar that "respects" gaps.

fufexan avatar Jul 06 '22 13:07 fufexan

The easieset way is just to know how many pixels wide your monitor is, and then set it to that minus whatever gap you want on each side times two.

Quinntyx avatar Jul 24 '22 16:07 Quinntyx

You could also just have the window take the whole width, have a transparent backgorund and set a padding of a certain number of pixel on it. IIRC the calc feature shouldn't require too much work to be implemented tho

viandoxdev avatar Jul 25 '22 22:07 viandoxdev

Oh that also works. Thanks for the tip!

fufexan avatar Jul 25 '22 22:07 fufexan

@viandoxdev

You could also just have the window take the whole width, have a transparent backgorund and set a padding of a certain number of pixel on it.

Hey, can you elaborate on this with an example? Not really sure how this would work.

musjj avatar Jul 29 '23 17:07 musjj

These workarounds don't work well when you don't know your monitor's resolution, such as when you spawn bars dynamically on all monitors of arbitrary sizes.

My workaround for now is to make the bars take a width as an argument, and use an expression like "${width -32}". Since I'm looping over the monitor data from hyprctl monitors -j to create the bars in the first place, I know their widths when creating my bars.

rosshadden avatar Jan 23 '24 18:01 rosshadden