diff options
author | 2025-03-06 12:33:48 +0300 | |
---|---|---|
committer | 2025-03-06 12:33:48 +0300 | |
commit | d440358ce6d4ec26dc8faf11c0e97e070d0fd596 (patch) | |
tree | 23f7af22345fa162638b325934e32066d18dd0aa /widget/bar | |
parent | fix: phantom icon in system tray (diff) | |
download | ags-config-d440358ce6d4ec26dc8faf11c0e97e070d0fd596.tar.gz ags-config-d440358ce6d4ec26dc8faf11c0e97e070d0fd596.tar.bz2 ags-config-d440358ce6d4ec26dc8faf11c0e97e070d0fd596.tar.lz ags-config-d440358ce6d4ec26dc8faf11c0e97e070d0fd596.tar.xz ags-config-d440358ce6d4ec26dc8faf11c0e97e070d0fd596.tar.zst ags-config-d440358ce6d4ec26dc8faf11c0e97e070d0fd596.zip |
feat: dynamic workspace updating
Diffstat (limited to '')
-rw-r--r-- | widget/bar/Bar.tsx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/widget/bar/Bar.tsx b/widget/bar/Bar.tsx index d89dc5f..3caca92 100644 --- a/widget/bar/Bar.tsx +++ b/widget/bar/Bar.tsx @@ -13,6 +13,13 @@ type NiriWorkspace = { active_window_id: number | null, }; +// Niri Event Stream +// This is used to dynamically update variables that should not be polling and +// reacting as fast as it can be possible +// NOTE: this works only in non-systemd environment on NixOS +// TODO: I should better write a module for Astal that communicate with socket +const niri = Variable("").watch("niri msg event-stream", (out, _prev) => out); + function getWorkspaces(): NiriWorkspace[] { // NOTE: this works only in non-systemd environment on NixOS // TODO: try to use Niri socket if it is documented @@ -57,10 +64,9 @@ type WorkspacesArguments = { }; function Workspaces(args: WorkspacesArguments) { - // NOTE: it is pretty inefficient and not so much responsive - // TODO: it would be better to use Niri socket in the future - const workspaces: Variable<NiriWorkspace[]> = Variable(getWorkspacesByOutput(args.connector)) - .poll(1000, () => getWorkspacesByOutput(args.connector)); + const workspaces: Variable<NiriWorkspace[]> = Variable.derive([niri], (_event) => { + return getWorkspacesByOutput(args.connector); + }); const workspaceIndices = [...Array(10).keys()]; return <box cssClasses={["Workspaces"]}> |