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.

Open URL

Open a URL in the default browser or application:

import { openURL } from "perry/system";

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

Dark Mode Detection

import { isDarkMode } from "perry/system";

if (isDarkMode()) {
  // Use dark theme colors
}
PlatformDetection
macOSNSApp.effectiveAppearance
iOSUITraitCollection
AndroidConfiguration.uiMode
WindowsRegistry (AppsUseLightTheme)
LinuxGTK settings
Webprefers-color-scheme media query

Clipboard

import { clipboardGet, clipboardSet } from "perry/system";

clipboardSet("Copied text!");
const text = clipboardGet();

Locale Detection

Get the device’s language as a 2-letter ISO 639-1 code:

import { getLocale } from "perry/system";

const lang = getLocale(); // "de", "en", "fr", "es", etc.

if (lang === "de") {
  // Use German translations
}
PlatformImplementation
macOS[NSLocale preferredLanguages]
iOS[NSLocale preferredLanguages]
AndroidLocale.getDefault().getLanguage()
WindowsLANG / LC_ALL environment variable
LinuxLANG / LC_ALL environment variable
tvOS[NSLocale preferredLanguages]
watchOSStub ("en")

App Icon Extraction

Get the icon for an application or file as a native Image widget. Useful for building app launchers, file browsers, and search UIs:

import { getAppIcon } from "perry/system";
import { VStack, HStack, Text, Image } from "perry/ui";

// macOS: pass .app bundle path
const finderIcon = getAppIcon("/System/Applications/Finder.app");
const safariIcon = getAppIcon("/Applications/Safari.app");

// Linux: pass .desktop file path
const firefoxIcon = getAppIcon("/usr/share/applications/firefox.desktop");

// Use icons in your UI
HStack(8, [
  finderIcon,
  Text("Finder"),
]);

Returns an Image widget handle (32x32 by default). Returns 0 if the icon cannot be loaded.

PlatformImplementation
macOSNSWorkspace.shared.icon(forFile:) — works for any file path, .app bundle, or folder
LinuxParses .desktop files for Icon= field, looks up via GTK icon theme, falls back to direct image file loading
WindowsNot yet implemented (returns 0)

Next Steps