diff --git a/CHANGELOG.md b/CHANGELOG.md index 18ea8b4..63f48f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,12 @@ ### Deprecated ### Removed ### Fixed + +* i3: fixed “missing workspace indicator” (_err: modules/i3.c:94: + workspace reply/event without 'name' and/or 'output', and/or 'focus' + properties_). + + ### Security ### Contributors diff --git a/doc/yambar-modules-i3.5.scd b/doc/yambar-modules-i3.5.scd index b2ba394..9184e46 100644 --- a/doc/yambar-modules-i3.5.scd +++ b/doc/yambar-modules-i3.5.scd @@ -37,7 +37,7 @@ with the _application_ and _title_ tags to replace the X11-only : True if the workspace has the urgent flag set | empty : bool -: True if the workspace is empty +: True if the workspace is empty (Sway only) | state : string : One of *urgent*, *focused*, *unfocused* or *invisible* (note: diff --git a/modules/i3.c b/modules/i3.c index bb51794..a7f3cc0 100644 --- a/modules/i3.c +++ b/modules/i3.c @@ -103,16 +103,18 @@ static bool workspace_from_json(const struct json_object *json, struct workspace *ws) { /* Always present */ - struct json_object *name, *output, *focus; + struct json_object *name, *output; if (!json_object_object_get_ex(json, "name", &name) || - !json_object_object_get_ex(json, "output", &output) || - !json_object_object_get_ex(json, "focus", &focus)) + !json_object_object_get_ex(json, "output", &output)) { - LOG_ERR("workspace reply/event without 'name' and/or 'output', " - "and/or 'focus' properties"); + LOG_ERR("workspace reply/event without 'name' and/or 'output' " + "properties"); return false; } + /* Sway only */ + struct json_object *focus = NULL; + json_object_object_get_ex(json, "focus", &focus); /* Optional */ struct json_object *visible = NULL, *focused = NULL, *urgent = NULL; @@ -122,7 +124,10 @@ workspace_from_json(const struct json_object *json, struct workspace *ws) const char *name_as_string = json_object_get_string(name); - const size_t node_count = json_object_array_length(focus); + const size_t node_count = focus != NULL + ? json_object_array_length(focus) + : 0; + const bool is_empty = node_count == 0; int name_as_int = workspace_name_as_int(name_as_string);