Collect other apps' menu bar items into a hamburger panel
The menu bar icon is now a hamburger whose panel gathers every other
app's status item via the Accessibility API, so tray icons no longer
need to be hunted down across the menu bar. Items can be opened from
the panel, and a best-effort toggle pushes them off the real menu bar
so they only live there.
💘 Generated with Crush
Assisted-by: Crush:deepseek-v4.1-flash
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import AppKit
|
||||
import ApplicationServices
|
||||
|
||||
/// Headless verification for `swift run SimpleTopBar --self-test`.
|
||||
/// Exercises the background-app overflow helpers and reports the live split
|
||||
@@ -45,6 +46,25 @@ func runSelfTest() {
|
||||
print("running=\(running.count) regular=\(regular) background=\(background)")
|
||||
check(regular + background == running.count, "every running app is classified")
|
||||
|
||||
// Menu bar item discovery degrades gracefully when it cannot read another
|
||||
// app's UI (accessibility not granted, or the element has no extras bar).
|
||||
let systemWide = AXUIElementCreateSystemWide()
|
||||
check(MenuBarItemManager.extrasMenuBar(of: systemWide) == nil, "no extras bar on a non-app element")
|
||||
check(MenuBarItemManager.children(of: systemWide) == nil, "no children on a non-app element")
|
||||
|
||||
let element = AXUIElementCreateSystemWide()
|
||||
let first = MenuBarItem(id: "1-0", pid: 1, appName: "A", title: "T", appIcon: NSImage(), element: element)
|
||||
let same = MenuBarItem(id: "1-0", pid: 1, appName: "A", title: "T", appIcon: NSImage(), element: element)
|
||||
let different = MenuBarItem(id: "1-1", pid: 1, appName: "A", title: "T", appIcon: NSImage(), element: element)
|
||||
check(first == same, "menu bar items compare by id and title")
|
||||
check(first != different, "different ids are not equal")
|
||||
|
||||
let authorized = AXIsProcessTrusted()
|
||||
print("accessibility authorized=\(authorized)")
|
||||
if authorized {
|
||||
print("menu bar items discovered=\(MenuBarItemManager.enumerate().count)")
|
||||
}
|
||||
|
||||
print(failures == 0 ? "ALL PASS" : "\(failures) FAILURE(S)")
|
||||
exit(failures == 0 ? 0 : 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user