From 2497f0519f347c6c05d959d5021631d8dc0d29e1 Mon Sep 17 00:00:00 2001 From: Daniel Albert Date: Sun, 22 May 2022 19:10:37 +0000 Subject: [PATCH] Fix #4: Add workaround for missing `focused` property in outputs If there is an inactive input, then the `focused` property may be missing in sway's response to a `get_output` message. This fix uses a feature of serde where default values for missing fields can be defined. Here, the `Default::default` for booleans is used, which is `false`. --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index 21ebbb8..b27c6b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,6 +105,7 @@ fn check_success(stream: &UnixStream) { #[derive(Serialize, Deserialize)] struct Output { name: String, + #[serde(default)] focused: bool, active: bool, }