Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T00:33:55.988Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

omega-window-list.swift

41 lines · 1.7 KB · text
1// List every window the window server knows about, with the owning process.
2//
3// The installed-observation collector needs this because a GPUI application
4// publishes no accessibility tree, and an application that publishes no
5// accessibility tree publishes no window list either: `System Events` reports
6// `count of windows` = 0 for a window that is plainly on the screen. The
7// window server still knows the window, so the collector reads the window from
8// here and captures it by identifier.
9//
10// Build:
11//     swiftc -O -o <dir>/omega-window-list script/omega-window-list.swift
12//
13// Output is one JSON array. `onscreen` is false for a window on a space that
14// is not the active one, which is why the collector captures by identifier
15// rather than by screen region.
16
17import Foundation
18import CoreGraphics
19
20guard let list = CGWindowListCopyWindowInfo([.optionAll], kCGNullWindowID) as? [[String: Any]] else {
21    FileHandle.standardError.write("cannot read the window list\n".data(using: .utf8)!)
22    exit(1)
23}
24
25var out: [[String: Any]] = []
26for window in list {
27    out.append([
28        "id": window[kCGWindowNumber as String] ?? 0,
29        "pid": window[kCGWindowOwnerPID as String] ?? 0,
30        "owner": window[kCGWindowOwnerName as String] ?? "",
31        "name": window[kCGWindowName as String] ?? "",
32        "layer": window[kCGWindowLayer as String] ?? 0,
33        "onscreen": window[kCGWindowIsOnscreen as String] ?? false,
34        "bounds": window[kCGWindowBounds as String] ?? [:],
35    ])
36}
37
38let data = try JSONSerialization.data(withJSONObject: out, options: [.prettyPrinted, .sortedKeys])
39FileHandle.standardOutput.write(data)
40FileHandle.standardOutput.write("\n".data(using: .utf8)!)
41
Served at tenant.openagents/omega Member data and write actions are omitted.