Restyle AGS bar as filled full-width bar with inverse corners

This commit is contained in:
Joshua Yuen 2026-09-12 15:01:46 -04:00
parent e3fcfc6812
commit e9f5c62d77
Signed by: josh
GPG Key ID: 530DA0331EFE99F5
3 changed files with 73 additions and 25 deletions

View File

@ -1,5 +1,7 @@
@use "palette" as *; @use "palette" as *;
$radius: 12px;
* { * {
all: unset; all: unset;
font-family: $font-family; font-family: $font-family;
@ -13,12 +15,19 @@
.bar { .bar {
background: $base01; background: $base01;
border-radius: 10px;
margin: 8px;
padding: 4px 12px; padding: 4px 12px;
color: $base05; color: $base05;
} }
.bar-corners {
background: transparent;
}
.corner {
background: transparent;
color: $base01;
}
.ws { .ws {
min-width: 20px; min-width: 20px;
border-radius: 6px; border-radius: 6px;

View File

@ -6,6 +6,38 @@ import { WifiWidget } from "./Wifi"
import { BatteryWidget } from "./Battery" import { BatteryWidget } from "./Battery"
import { PowerWidget } from "./Power" import { PowerWidget } from "./Power"
const RADIUS = 12
// paints the concave sliver below the bar at the screen edge: the r x r
// square minus the quarter disk where the wallpaper shows through
function Corner({ side }: { side: "left" | "right" }) {
return (
<drawingarea
className="corner"
widthRequest={RADIUS}
heightRequest={RADIUS}
halign={side === "left" ? Gtk.Align.START : Gtk.Align.END}
onDraw={(self, cr) => {
const w = self.get_allocated_width()
const h = self.get_allocated_height()
const c = self.get_style_context().get_color(Gtk.StateFlags.NORMAL)
cr.setSourceRGBA(c.red, c.green, c.blue, c.alpha)
if (side === "left") {
cr.moveTo(0, 0)
cr.lineTo(w, 0)
cr.arcNegative(w, h, w, -Math.PI / 2, -Math.PI)
} else {
cr.moveTo(w, 0)
cr.lineTo(0, 0)
cr.arc(0, h, w, -Math.PI / 2, 0)
}
cr.closePath()
cr.fill()
}}
/>
)
}
export default function Bar(gdkmonitor: Gdk.Monitor) { export default function Bar(gdkmonitor: Gdk.Monitor) {
const { TOP, LEFT, RIGHT } = Astal.WindowAnchor const { TOP, LEFT, RIGHT } = Astal.WindowAnchor
const volume = VolumeWidget(gdkmonitor) const volume = VolumeWidget(gdkmonitor)
@ -35,6 +67,7 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
anchor={TOP | LEFT | RIGHT} anchor={TOP | LEFT | RIGHT}
application={App} application={App}
> >
<box vertical>
<centerbox className="bar"> <centerbox className="bar">
<box <box
className="bar-left" className="bar-left"
@ -58,6 +91,12 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
{right} {right}
</box> </box>
</centerbox> </centerbox>
<box className="bar-corners">
<Corner side="left" />
<box hexpand />
<Corner side="right" />
</box>
</box>
</window> </window>
), ),
...popups, ...popups,

View File

@ -112,7 +112,7 @@ export default function Notifications(gdkmonitor: Gdk.Monitor) {
anchor={TOP | RIGHT} anchor={TOP | RIGHT}
exclusivity={Astal.Exclusivity.IGNORE} exclusivity={Astal.Exclusivity.IGNORE}
keymode={Astal.Keymode.NONE} keymode={Astal.Keymode.NONE}
marginTop={48} marginTop={54}
marginRight={8} marginRight={8}
visible={bind(notifd, "notifications").as((ns) => ns.length > 0)} visible={bind(notifd, "notifications").as((ns) => ns.length > 0)}
> >