I have checked https://gjs-docs.gnome.org/meta9~9_api/meta.window#method-get_display
I can get
[
{
"class": "Nemo-desktop",
"class_instance": "nemo-desktop",
"pid": 1949,
"id": 3315575505,
"maximized": 0,
"focus": false,
"title": "Desktop"
},
]
Using
let win = global.get_window_actors()
.map(a => a.meta_window)
.map(w => ({ class: w.get_wm_class(), class_instance: w.get_wm_class_instance(), pid: w.get_pid(), id: w.get_id(), maximized: w.get_maximized(), focus: w.has_focus(), title: w.get_title()}));
return JSON.stringify(win);
I also want to get Width, Height, X-Coordinate, Y-Coordinate, ActiveWorkSpace and IsViewable for each window.
Here, ActiveWorkSpace
is the workspace on which the window is.
Here, IsViewable
is the value shown with in xwininfo
’s output’s Map State: IsViewable
. This is same as xdotools
’s --onlyvisible
One pore issue with the code. The output is not in json format.
The output is actually like:
('[
{
"class": "Nemo-desktop",
"class_instance": "nemo-desktop",
"pid": 1949,
"id": 3315575505,
"maximized": 0,
"focus": false,
"title": "Desktop"
},
]',)
So I have to run gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Extensions/Windows --method org.gnome.Shell.Extensions.Windows.List | cut -c 3- | rev | cut -c4- | rev | jq .
to get accurate output. I would like to have a json output.
How can i achieve these goals.