Skip to main content
Glama
CommandHelpers.swift1.67 kB
import AppKit import ApplicationServices @preconcurrency import ArgumentParser import AXorcist import Foundation import PeekabooCore import PeekabooFoundation // MARK: - Element Extensions for System UI extension Element { @MainActor func menuBar() -> Element? { guard let menuBar = attribute(Attribute<AXUIElement>("AXMenuBar")) else { return nil } return Element(menuBar) } @MainActor static func systemWide() -> Element { Element(AXUIElementCreateSystemWide()) } @MainActor func focusedApplication() -> Element? { guard let app = attribute(Attribute<AXUIElement>("AXFocusedApplication")) else { return nil } return Element(app) } } // MARK: - Action Extensions extension Attribute where T == String { static var hide: Attribute<String> { Attribute("AXHide") } static var unhide: Attribute<String> { Attribute("AXUnhide") } } // MARK: - Application Finding /// Async wrapper for finding applications using PeekabooCore services @MainActor func findApplication(identifier: String) async throws -> (app: Element, runningApp: NSRunningApplication) { // Use PeekabooServices to find the application let appInfo = try await PeekabooServices.shared.applications.findApplication(identifier: identifier) // Get the NSRunningApplication guard let runningApp = NSRunningApplication(processIdentifier: appInfo.processIdentifier) else { throw PeekabooError.appNotFound(identifier) } let element = Element(AXUIElementCreateApplication(runningApp.processIdentifier)) return (app: element, runningApp: runningApp) }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/steipete/Peekaboo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server