Skip to content

system

system

Small platform queries and actions.

The OS name and processor count, clipboard read and write, opening a URL in the browser, and battery and power info. These are thin wrappers over SDL3.

getOS

proc getOS(): string

The name of the operating system, like "macOS", "Linux" or "Windows".

Returns

string

getProcessorCount

proc getProcessorCount(): int

The number of logical CPU cores.

Returns

int

getClipboardText

proc getClipboardText(): string

The current clipboard text, or an empty string if there is none.

Returns

string

setClipboardText

proc setClipboardText(text: string)

Put text on the clipboard.

Parameters

  • text (string)

hasClipboardText

proc hasClipboardText(): bool

Whether the clipboard holds any text.

Returns

bool

openURL

proc openURL(url: string): bool

Open a URL in the default browser. Returns false on failure.

Parameters

  • url (string)

Returns

bool

getPowerInfo

proc getPowerInfo(): tuple[state: string, percent: int, seconds: int]

Battery state, charge percent and seconds of charge left. The state is one

of "battery", "charging", "charged", "nobattery" or "unknown", and percent and seconds are -1 when they cannot be determined.

Returns

tuple[state: string, percent: int, seconds: int]

Generated with mkdocstrings-nim