From 62a705ee419da0e554da0c465d416bda4d1ee304 Mon Sep 17 00:00:00 2001 From: candifloss Date: Wed, 9 Sep 2026 12:53:31 +0530 Subject: [PATCH] Update X desktop info handling - Update initial value for `xdistate` - Function for current window name --- nbcl/panel/panel_section_center.nbcl | 4 +--- nbcl/vars/vars.nbcl | 2 +- nbcl/vars/xdi.nbcl | 12 ++++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/nbcl/panel/panel_section_center.nbcl b/nbcl/panel/panel_section_center.nbcl index 52aa37f..3bb8824 100644 --- a/nbcl/panel/panel_section_center.nbcl +++ b/nbcl/panel/panel_section_center.nbcl @@ -17,9 +17,7 @@ fn panel_center() { truncate = true truncate_left = false limit_width = config.panel_windowtitle_maxchars - text = global("xdistate").mutate(|val|{ - json.parse(val).active_window.name - }) + text = xdi.windowname() } } } \ No newline at end of file diff --git a/nbcl/vars/vars.nbcl b/nbcl/vars/vars.nbcl index c3ec12a..db71212 100644 --- a/nbcl/vars/vars.nbcl +++ b/nbcl/vars/vars.nbcl @@ -1,4 +1,4 @@ -import "nbcl/vars/xdi.nbcl" as xdi +import "nbcl/vars/xdi.nbcl" as xdi { * } Poll "time_hhmm" { initial = "00:00" diff --git a/nbcl/vars/xdi.nbcl b/nbcl/vars/xdi.nbcl index ce515a5..262eeaf 100644 --- a/nbcl/vars/xdi.nbcl +++ b/nbcl/vars/xdi.nbcl @@ -1,9 +1,13 @@ import core.json Listen "xdistate" { - initial = "{}" - cmd = "xdi -f" + initial = "{\"active_window\":{\"id\":0,\"name\":\"\",\"class\":\"\"},\"workspaces\":[{\"id\":0,\"current\":true,\"windows\":[]}]}" + cmd = "/usr/local/bin/xdi -f" } - -#let wmstate = \ No newline at end of file +# Usage: xdi.windowname() +fn windowname() { + global("xdistate").mutate(|val|{ + json.parse(val).active_window.name + }) +} \ No newline at end of file