import { App, Astal, Gdk, Gtk } from "astal/gtk3" import Workspaces from "./Workspaces" import Logo from "./Logo" import Clock from "./Clock" import { BatteryWidget } from "./Battery" import QuickSettings from "./QuickSettings" 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 ( { const w = self.get_allocated_width() const h = self.get_allocated_height() // bar color comes from the parent strip so the sliver gets the // same bar-bg + module-bg stack as the pills const bar = self .get_parent()! .get_style_context() .get_color(Gtk.StateFlags.NORMAL) const mod = self .get_style_context() .get_color(Gtk.StateFlags.NORMAL) const trace = () => { 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.setSourceRGBA(bar.red, bar.green, bar.blue, bar.alpha) trace() cr.fillPreserve() cr.setSourceRGBA(mod.red, mod.green, mod.blue, mod.alpha) cr.fill() }} /> ) } export default function Bar(gdkmonitor: Gdk.Monitor) { const { TOP, LEFT, RIGHT } = Astal.WindowAnchor const battery = BatteryWidget(gdkmonitor) const quicksettings = QuickSettings(gdkmonitor) const right: Array = [] if (battery.button) right.push(battery.button) right.push(quicksettings.button) const popups: Array = [] if (battery.popup) popups.push(battery.popup) popups.push(quicksettings.popup) return [ ( {right} ), ...popups, ] }