; The island machinery, adopted from Murzchnvok/polybar-collection. ; ; [bar/main] is one full-width, fully transparent window. An island is just a ; run of modules that paint their own background, opened and closed by these ; two text modules: a half circle drawn in the island colour at font-1 ; (%{T2}). The result is a rounded block only as wide as what is inside it -- ; no bar widths to measure and no second bar window to keep in sync. ; ; The corner radius is font-1's *size*, and the trick is that the glyph is far ; taller than the bar: at 30pt it is 48px tall, the bar keeps the middle 32px, ; and a shallow 6px corner is all that shows. Bigger size, flatter corner -- ; the inset at the bar's top and bottom edge works out to about ; ; 0.636 * em * (1 - sqrt(1 - (16 / (0.6065 * em))^2)) em = size * 4/3 ; ; The %{O-8} is what keeps the cap from being fat: the glyph's advance is ; 0.6em (24px at 30pt), far more than the corner needs, so the cursor is ; pulled back 8px to leave a 16px cap. Which side of the glyph the pullback ; goes on matters. cap-left trims after, because its ink runs to the right ; into the next module's background, which is painted afterwards and covers ; it. cap-right trims before, because its ink runs left over the *previous* ; module -- so keep that pullback under that module's format-padding (10px) ; or the cap will paint over the last of its text. ; ; The contract for anything that goes in an island: set a background and some ; padding on every format the module can show, e.g. ; ; format-background = ${colors.background} ; format-padding = 1 ; ; A format without a background leaves a see-through hole in the island. Note ; that it is format--background for modules with named formats ; (mounted, volume, connected, ...) -- there is no fallback to a bare ; format-background. [module/cap-left] type = custom/text label = %{T2}%{T-}%{O-8} label-foreground = ${colors.background} [module/cap-right] type = custom/text label = %{O-8}%{T2}%{T-} label-foreground = ${colors.background} ; A transparent spacer, for a real gap between two islands on the same side. ; One font-1 space, so it is a cap's worth of nothing: 24px. [module/gap] type = custom/text label = %{T2} %{T-} label-foreground = ${colors.transparent} ; vim:ft=dosini