Sway: Remove extraneous properties from IPC command get_outputs

Created on 21 Sep 2018  路  11Comments  路  Source: swaywm/sway

for a setup with two monitors:

$ swaymsg -t get_outputs | grep focused
     "focused": false,
     "focused": false,

$ swaymsg -t get_version
sway version 1.0-alpha.5-364-g15dadaaa (Sep 18 2018, branch 'makepkg')
enhancement good first issue

Most helpful comment

I don't think so. Run swaymsg -t get_outputs -r in both sway and i3 and compare them.

All 11 comments

This is intended. focused is only true for the single focused node (not the ancestors), so it can never be true on an output.

The i3 docs (https://i3wm.org/docs/ipc.html) confirm this:

... will result in eventually reaching the one node with focused set to true

And looking at the i3 code, it's only set for one node (focused is a global variable): https://github.com/i3/i3/blob/ac88d06632b6235e51d89806b7889ba5bfb9eb78/src/ipc.c#L420

Okay. Then that field being there at all is a bit misleading though. I just checked and in i3, the field is not part of the get_outputs IPC command output.

Confirmed. An example of what they return is:

{
    "name": "LVDS-1",
    "active": true,
    "primary": true,
    "rect": {
      "x": 0,
      "y": 0,
      "width": 1920,
      "height": 1080
    },
    "current_workspace": "3"
},

I'd support removing irrelevant elements from our get_outputs reply.

Also, as an aside: My main goal was to query the name of the currently focused output. I managed to do that after reading up on jq, which I had seen used for filtering out information from i3's ipc previously. This is what I came up with, for anyone looking to do the same thing:

swaymsg -t get_tree | jq -r '.nodes[] | select(recurse(.nodes[], .floating_nodes[]) | .focused).name'

May I ask what other properties besides "focused" are considered extraneous?

Probably anything that isn't in the i3 reply.

Not everything that isn't in i3 is extraneous. Some of the properties have to be included by sway to handle output configuration that is done by xrandr in Xorg.

$ swaymsg -t get_outputs | grep focused
     "focused": true,
     "focused": false,

looks like now we have some useful outputs?

@ianyfan It looks like this can be closed now.

I don't think so. Run swaymsg -t get_outputs -r in both sway and i3 and compare them.

Ah OK I had conflated the issue of focused always returning false with the original issue of non-conformance with the i3 IPC.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emersion picture emersion  路  4Comments

johanhelsing picture johanhelsing  路  3Comments

marcoms picture marcoms  路  3Comments

WhyNotHugo picture WhyNotHugo  路  3Comments

DpoBoceka picture DpoBoceka  路  4Comments