Closed nikitabobko closed 1 month ago
This would save me a lot for a Raycast extension in developing.
Right now I’m using —format to retrieve a JSON object-like list of windows in focused workspace but when doing JSON.parse it breaks if a window has “ in the %{window-title}.
It's an open question how
--json
should interact with--format
flag that those commands also have
I think it should work this way:
$ aerospace list-windows --all --json --format "%{app-name}"
[
{ "app-name": "Google Chrome" },
{ "app-name": "IntelliJ IDEA" }
]
$ aerospace list-windows --all --json --format "%{app-name} %{app-pid}%{app-bundle-id}"
[
{
"app-name": "Google Chrome",
"app-pid": 354,
"app-bundle-id": "com.google.chrome",
},
{
"app-name": "IntelliJ IDEA",
"app-pid": 132,
"app-bundle-id": "org.jetbrains.intellij",
}
]
$ aerospace list-windows --all --json --format "%{app-name} | %{app-pid}"
error: non-whitespace characters are not allowed in <output-format> when --json is used
This looks good to me. The output is the exact one I “hacked” for the Raycast extension.
Something I struggled, but don’t know up to which point you have control is: If you ask for the %{window-title}, and this has double quotes (for example a browser title for a web), they should be escaped, because if not and you try to JSON.parse() the output it will give errors.
Released in 0.15.0
All query commands must provide
--json
flag to make it easier to use them for reliable scripting.Currently presented query commnads:
list-windows
list-monitors
list-apps
list-workspaces
(I plan to drop this command)list-exec-env-vars
It's an open question how
--json
should interact with--format
flag that those commands also have