Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Other System APIs

Additional platform-level APIs. Every snippet below is excerpted from a real file CI compiles on every PR — see docs/examples/system/snippets.ts for the perry/system pieces and docs/examples/ui/events/snippets.ts for clipboard.

Open URL

Open a URL in the default browser or application:

openURL("https://example.com")
PlatformImplementation
macOSNSWorkspace.open
iOSUIApplication.open
AndroidIntent.ACTION_VIEW
WindowsShellExecuteW
Linuxxdg-open
Webwindow.open

Dark Mode Detection

if (isDarkMode()) {
    console.log("Dark mode is active")
}
PlatformDetection
macOSNSApp.effectiveAppearance
iOSUITraitCollection
AndroidConfiguration.uiMode
WindowsRegistry (AppsUseLightTheme)
LinuxGTK settings
Webprefers-color-scheme media query

Clipboard

Clipboard helpers live in perry/ui (not perry/system):

// Copy to clipboard
clipboardWrite("Hello, clipboard!")

// Read from clipboard
const text = clipboardRead()
log.set(`clipboard length: ${text.length}`)

Device Identity

console.log(`device idiom: ${getDeviceIdiom()}`)
console.log(`device model: ${getDeviceModel()}`)

getDeviceIdiom() returns the broad form factor ("phone", "pad", "mac", "tv", …); getDeviceModel() returns the platform-specific model identifier ("iPhone15,2", "MacBookPro18,3", etc.).

Next Steps