coquille/widget/Workspaces.tsx

25 lines
669 B
TypeScript
Raw Normal View History

2025-02-11 17:51:09 +01:00
import { bind } from "astal";
import Hyprland from "gi://AstalHyprland";
export const Workspaces = () => {
const hypr = Hyprland.get_default();
return (
<box cssClasses={["Workspaces"]}>
{bind(hypr, "workspaces").as((wss) =>
wss
.filter((ws) => !(ws.id >= -99 && ws.id <= -2)) // filter out special workspaces
.sort((a, b) => a.id - b.id)
.map((ws) => (
<button
cssClasses={bind(hypr, "focusedWorkspace").as((fw) =>
ws === fw ? ["focused"] : [""],
)}
onClicked={() => ws.focus()}
></button>
)),
)}
</box>
);
};