import { App, Astal, Gtk, Gdk } from "astal/gtk3" import { exec, monitorFile, Variable } from "astal" import { Button, Label } from "astal/gtk3/widget"; import Pango from "gi://Pango?version=1.0"; const time = Variable("").poll(1000, "date") type Id = number interface SwayNodeCommon { id: Id, orientation: 'horizontal' | 'vertical' | 'none', name: string, focus: Id[], rect: Rect, deco_rect: Rect, window_rect: Rect, geometry: Rect, } type SwayNode = SwayOutput | SwayRoot | SwayCon | SwayWorkspace; type Rect = { x: number, y: number, width: number, height: number } interface SwayWorkspace extends SwayNodeCommon { type: 'workspace', nodes: SwayCon[] } interface SwayCon extends SwayNodeCommon { type: 'con', window_properties?: { class: string, instance: string, title: string, window_role: string, window_type: string, }, } interface SwayOutput extends SwayNodeCommon { type: 'output', nodes: SwayWorkspace[], focused: boolean, } interface SwayRoot extends SwayNodeCommon { type: 'root', nodes: SwayOutput[] } const swayTree = Variable({} as SwayRoot | { type: undefined }).poll(1000, "swaymsg -t get_tree", text => JSON.parse(text) as SwayRoot ) function omit(obj: T, ...ks: K[]): Omit { return Object.fromEntries(Object.entries(obj).filter(it => !ks.includes(it[0] as K))) as any } function Monitor(props: { monitor: SwayOutput }) { return <> {props.monitor.nodes.map(ws => )} } function Workspace(props: { ws: SwayWorkspace, focused: boolean }) { return <> {props.ws.nodes.map(window => )} } export default function Bar(gdkmonitor: Gdk.Monitor) { const { TOP, LEFT, RIGHT, BOTTOM } = Astal.WindowAnchor return {swayTree(root => !root.type ? null : root.nodes .map(monitor => monitor.name.startsWith("_") ? null : ) .filter(it => it) )} }