about summary refs log tree commit diff
path: root/src/facility
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-11-25 03:40:14 -0700
committerIrene Knapp <ireneista@irenes.space>2026-11-25 04:16:31 -0700
commitb65303ede0750e9d83df4d2c5df67f143c9171c4 (patch)
treea8d15bdaa3493ed7a8b66092e6f58cf6ebe1909f /src/facility
parent5ec7ae026ce9d8c48ef5f0590a300fa308efa487 (diff)
i3 mode module fully works now; some API changes
most notably, modules now have a way to request immediate redrawing

Change-Id: Id060c88d3ab484addfd8ca574fbc4e2ffdbb5c8f
Force-Push: yes
Diffstat (limited to 'src/facility')
-rw-r--r--src/facility/i3.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/facility/i3.rs b/src/facility/i3.rs
index d914548..53258f8 100644
--- a/src/facility/i3.rs
+++ b/src/facility/i3.rs
@@ -530,3 +530,27 @@ fn parse_success_object(json: &[u8]) -> Result<bool> {
   }
 }
 
+
+pub fn parse_change_string(json: &[u8]) -> Result<String> {
+  let mut parser = SliceJsonParser::new(json);
+
+  if let JsonEvent::StartObject = parser.parse_next()? { } else {
+    return Err(Error::custom("Reading i3 JSON, expected object start."));
+  }
+
+  if let JsonEvent::ObjectKey(key) = parser.parse_next()? {
+    if key == "change" {
+      if let JsonEvent::String(result) = parser.parse_next()? {
+        /* That's our answer; exit early. */
+        return Ok(result.into_owned());
+      } else {
+        return Err(Error::custom("Reading i3 JSON, expected string."));
+      }
+    } else {
+      return Err(Error::custom("Reading i3 JSON, expected \"change\" key."));
+    }
+  } else {
+    return Err(Error::custom("Reading i3 JSON, expected object key."));
+  }
+}
+