19 lines
677 B
TypeScript
19 lines
677 B
TypeScript
|
import Hyprland from "gi://AstalHyprland";
|
||
|
import { bind, Variable } from "astal";
|
||
|
|
||
|
export default function Workspace() {
|
||
|
const hypr = Hyprland.get_default();
|
||
|
const lastWorkspaceId = Variable(hypr.focusedWorkspace.id);
|
||
|
|
||
|
return <button hasFrame={false}>
|
||
|
{bind(hypr, "focusedWorkspace").as(workspace => {
|
||
|
// This is a hack; sometimes when disconnecting monitor
|
||
|
// focusedWorkspace is null for a while.
|
||
|
// Therefore an error occurs when trying to reference id.
|
||
|
if (workspace) lastWorkspaceId.set(workspace.id)
|
||
|
|
||
|
return `workspace ${workspace?.id ?? lastWorkspaceId.get()}`
|
||
|
})}
|
||
|
</button>
|
||
|
}
|