summaryrefslogtreecommitdiff
path: root/widget/bar
diff options
context:
space:
mode:
authorLibravatar Mora Unie Youer <[email protected]>2025-03-06 12:33:48 +0300
committerLibravatar Mora Unie Youer <[email protected]>2025-03-06 12:33:48 +0300
commitd440358ce6d4ec26dc8faf11c0e97e070d0fd596 (patch)
tree23f7af22345fa162638b325934e32066d18dd0aa /widget/bar
parentfix: phantom icon in system tray (diff)
downloadags-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.tsx14
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"]}>