Waybar: Missing workspace indicators

Created on 15 May 2020  路  8Comments  路  Source: Alexays/Waybar

Hello, today, out of the blue, waybar stopped showing me the active workspaces for Sway.

Waybar or Sway both do not issue any error on start, but one curious thing I've discovered later is that it seems that Sway isn't reporting any outputs:

swaymsg -t get_outputs
Output eDP-1 '(null) (null) (null)' (inactive)
Output DP-3 '(null) (null) (null)' (inactive)

I know this might be better an issue for the Sway issue tracker, but perhaps someone else has already encountered similar?

Thanks!

question

All 8 comments

Hi, I have the same problem since yesterday after a system upgrade on a gentoo system. No idea what caused it though.

% swaymsg -t get_outputs
Output DP-1 '(null) (null) (null)' (inactive)

Output HDMI-A-1 '(null) (null) (null)' (inactive)

So I just checked the dependencies. The issue comes with json-c-0.14, json-c-0.13.1 seems fine. My workspaces are back in waybar. :smiley:

On Ubuntu, this was broken by the upgrade to libjson-c4 0.13.1+dfsg-7ubuntu0.1. According to the package changelog, the change was later reverted in 0.13.1+dfsg-7ubuntu0.2, which is probably just around the corner.

As a temporary workaround, it works to downgrade to 0.13.1+dfsg-7:

sudo apt install libjson-c4=0.13.1+dfsg-7

After the downgrade, you need to restart Sway, not just Waybar.

Thank you! I will look into this and be back

I believe issue is somewhere in sway <-> swaymsg interoperability.

From swaymsg/main.c:

    json_object_object_get_ex(o, "active", &active);
       ...
    if (json_object_get_boolean(active)) {
       ...
        } else {
        printf(
            "Output %s '%s %s %s' (inactive)\n",
            json_object_get_string(name),
            json_object_get_string(make),
            json_object_get_string(model),
            json_object_get_string(serial)
        );
        }

But running swaymsg -r -t get_outputs gives me this:

$ swaymsg -t get_outputs  -r
[
  {
    "id": 3,
    "name": "eDP-1",
    "rect": {
      "x": 0,
      "y": 0,
      "width": 1500,
      "height": 1000
    },
    "focus": [
      28,
      4,
      6,
      8,
      11
    ],
    "border": "none",
    "current_border_width": 0,
    "layout": "output",
    "orientation": "none",
    "percent": 1.0,
    "window_rect": {
      "x": 0,
      "y": 0,
      "width": 0,
      "height": 0
    },
    "focused": true
  }
]

Note that there is no "active" field.

Yep, this line in sway/ipc-json.c fails with -1:

    json_object_object_add(object, "active", json_object_new_boolean(true));

Well, I believe I have the answer:

$ cat test.c
#include <err.h>
#include <stdbool.h>
#include <stdio.h>

#include <json.h>

int
main(void)
{
    struct json_object  *root;
    char             id[32];

    if ((root = json_object_new_object()) == NULL)
        errx(1, "cannot create new JSON object");

    for (size_t i = 0; i < 64; ++i) {
        snprintf(id, sizeof(id), "%lu", i); 
        printf("adding boolean #%lu...\n", i);
        if (json_object_object_add(root, id,
                json_object_new_boolean(true)) != 0)
            errx(1, "cannot add boolean value %s to JSON object", id);
    }

    return 0;
}
$ ./test
adding boolean #0...
adding boolean #1...
adding boolean #2...
adding boolean #3...
adding boolean #4...
adding boolean #5...
adding boolean #6...
adding boolean #7...
adding boolean #8...
adding boolean #9...
adding boolean #10...
adding boolean #11...
test: cannot add boolean value 11 to JSON object

Works fine with 0.13.1, breaks with 0.14.0. In Gentoo working version is 0.14-r1, 0.14-r2 contains security fix that breaks things.

On Ubuntu, this was broken by the upgrade to libjson-c4 0.13.1+dfsg-7ubuntu0.1. According to the package changelog, the change was later reverted in 0.13.1+dfsg-7ubuntu0.2, which is probably just around the corner.

As a temporary workaround, it works to downgrade to 0.13.1+dfsg-7:

sudo apt install libjson-c4=0.13.1+dfsg-7

After the downgrade, you need to restart Sway, not just Waybar.

The package has been fixed in Ubuntu already - everything is working good for me again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cinghiopinghio picture cinghiopinghio  路  4Comments

docquantum picture docquantum  路  5Comments

xajler picture xajler  路  5Comments

DyslexicAtheist picture DyslexicAtheist  路  4Comments

ForTheReallys picture ForTheReallys  路  5Comments