const hyprland = await Service.import("hyprland") function ClientTitle() { return Widget.Label({ class_name: "client-title", max_width_chars: 30, truncate: "end", label: hyprland.active.client.bind("title"), }) } function Workspaces() { const activeId = hyprland.active.workspace.bind("id") const workspaces = hyprland.bind("workspaces") .as(ws => ws.map(({ id }) => id > 0 ? Widget.Button({ on_clicked: () => hyprland.messageAsync(`dispatch workspace ${id}`), child: Widget.Label(`${id}`), class_name: activeId.as(i => `${i === id ? "focused" : "other"}`), margin_left: 10, }) : null ).sort((a, b) => { return a && b ? Number(a.child.label) - Number(b.child.label) : a ? -1 : 1 })) return Widget.CenterBox({ spacing: 8, start_widget: Widget.Box({ class_name: "workspaces", spacing: 0, children: workspaces }), end_widget: ClientTitle(), }) } export default Workspaces