import type { Result } from "@cprussin/option-result"; import type { DomicileHost } from "../domicile-host"; import type { InhibitorAction } from "../inhibitor-action"; import type { KeymapChoice, Keymaps } from "../keymap-choice"; import type { KnownAgents } from "../portal"; import type { PreviewedWindow } from "../previewed-window"; import type { CommandRan, Link, ShellBinding, ShellCommand, ShellCommandHelp } from "../shell-command"; import type { ByteRange, DbusBody, DbusCall, DbusMatch, DbusSignal, DirEntry, Listening, Ran, SpawnOptions, Stat, Subprocess, SystemError, UnlockRefused, VirtualMonitor, VirtualMonitorMode, Watch } from "../system"; import { Listened, ScreenshotKept } from "../system"; import type { Bell, WindowState } from "../window-state"; import { WindowRequest } from "../window-state"; /** * The calls. A relative path starts at the home. The compositor runs each in * the desktop's environment and refuses most of them while the desktop is * locked. */ export type System = { /** The whole file, or `length` bytes from `offset`: fewer at its end. */ readFile: (path: string, range?: ByteRange) => Promise>; readTextFile: (path: string) => Promise>; /** Atomic by default: a reader never sees half a file. Writes under `/sys` and `/proc` must not be. */ writeFile: (path: string, data: Uint8Array | string, options?: { atomic?: boolean; }) => Promise>; /** Fails {@link SystemErrorKind.AlreadyExists} if anything has the name. */ createDir: (path: string) => Promise>; readDir: (path: string) => Promise>; stat: (path: string) => Promise>; watch: (path: string) => Promise>; /** Run `argv` directly, with no shell; `argv[0]` is looked up on `PATH`. */ spawn: (argv: readonly string[], options?: SpawnOptions) => Promise>; /** {@link System.spawn}, collected as text once it ends. */ run: (argv: readonly string[], options?: Omit) => Promise>; dbusCall: (call: DbusCall) => Promise>; dbusMatch: (match: DbusMatch) => Promise>, SystemError>>; /** * Take a screenshot as an interactive Screenshot portal call takes one, as * if the shell were the application: the desk freezes, `` * draws the screenshot dialog, and the area picked is saved under * `$XDG_PICTURES_DIR/Screenshots/`, or copied to the clipboard instead when * the user presses Ctrl+C. Resolves with where it went. A call while the * shell's screenshot dialog is up resolves as that dialog does, and shows * no second one. */ screenshot: () => Promise>; /** * Record the screen: `` draws the screen cast picker, and * what is picked is recorded, with its sound, until its toolbar stops it. * Resolves with the WebM under `$XDG_VIDEOS_DIR/Screen recordings/`, or * fails `Canceled` when the picker is dismissed or the recording discarded. */ screenRecord: () => Promise>; /** * Draw `window` as it last drew itself, as a `data:` URL of a PNG, for a * picker to preview a window that is not on screen. A browser window's page * draws while it is captured, so a hidden one draws too. */ previewWindow: (window: PreviewedWindow) => Promise>; /** * Hear each command `domicile send-shell` sends. Every page listening hears * every command, and answers each with `answerShellCommand`; `send-shell` * fails when no page ran it. `commands` describes what this page runs, for * `domicile list-shell-commands`, and `bindings` the keys that run them, for * `domicile list-bindings`. Allowed while the desktop is locked. */ shellCommands: (commands: readonly ShellCommandHelp[], bindings: readonly ShellBinding[]) => Promise, SystemError>>; /** * Open links of `schemes`, such as `mailto`, for the desktop: hear each one * `domicile open` (and so `xdg-open` and applications' links) and the * Email portal hand over, instead of the application that opens the * scheme. The page that claimed a scheme last gets its links. */ claimLinks: (schemes: readonly string[]) => Promise, SystemError>>; /** * Say that this page ran the command numbered `sent`, with what * `domicile send-shell` prints if anything, or with `Err`, why it did not. */ answerShellCommand: (sent: number, ran: Result) => Promise>; /** * Hear `true` once nobody has been at the desk for `seconds`, and `false` * on the next input. Idle inhibitors hold it off as they hold off * blanking. `seconds` must be at least 1. Allowed while the desktop is * locked. See docs/SHELL-IDLE-AND-LOCK.md. */ idleAfter: (seconds: number) => Promise, SystemError>>; /** * As `idleAfter`, `seconds` before the screens blank, to dim or count * down. Silent when the screens never blank, or blank sooner. */ idleBeforeBlanking: (seconds: number) => Promise, SystemError>>; /** * Hear what holds the desktop awake: the app ids of the windows and * applications whose idle inhibitors keep the screens from blanking, to name * with `useApps`. The shell's own hold * through the portal is `"domicile"`. Heard at once, then on each change. * Allowed while the desktop is locked. See docs/IDLE.md. */ idleHolds: () => Promise, SystemError>>; /** * Hear why each passphrase sent with `unlock` did not open the desk. Every * page listening hears every refusal. Allowed while the desktop is locked. */ unlockRefusals: () => Promise, SystemError>>; /** * Replace the `xdg_toplevel` states the shell set on window `appId`, and * configure it. States last until the shell replaces them, across reloads. * Fails {@link SystemErrorKind.NotFound} for a window the compositor does * not know. Allowed while the desktop is locked. */ setWindowStates: (appId: string, states: readonly WindowState[]) => Promise>; /** * Draw `display` (a display's `name`, connector or panel name, as a * profile matches it), or every monitor when it is left * out, as if its white were a light of `kelvin`, 1000 to 6500, as a * night light does; 6500 draws colors as they are. Fades from the color * drawn: about 1.5 s to switch a night light on, a few frames for a small * step. Every monitor's replaces each one's. Lasts until the shell sets another, across reloads. Changes * nothing on a nested desktop, nor on a monitor a night-light app such as * gammastep holds. Allowed while the desktop is locked. */ setColorTemperature: (kelvin: number, display?: string) => Promise>; /** * Turn every monitor off now, keeping windows and workspaces as they are. * Input more than a second later lights them again, as does * {@link System.wakeDisplays}. With `display` (a display's `name`, connector * or panel name, as a profile matches it), turn * only that one off: it keeps its place and windows, and sleeps through * input until woken. Fails {@link SystemErrorKind.NotFound} for a display * the desktop does not have. Allowed while the desktop is locked. See * docs/IDLE.md#sleeping-on-demand. */ sleepDisplays: (display?: string) => Promise>; /** The agents let in now, and those let in without asking. */ agents: () => Promise>; /** * Make remembered agent `agent` ask again next time. Succeeds whether or * not it was remembered. */ forgetAgent: (agent: string) => Promise>; /** * Light the monitors again, after {@link System.sleepDisplays} or idle * blanking, or only `display`. Allowed while the desktop is locked. */ wakeDisplays: (display?: string) => Promise>; /** * Hear each maximize and fullscreen request a client makes. The compositor * grants none; grant one with {@link System.setWindowStates}. Allowed while * the desktop is locked. */ windowRequests: () => Promise, SystemError>>; /** * Hear each time a client rings the bell, such as a terminal's `\a`. The * compositor makes no sound. Allowed while the desktop is locked. */ bells: () => Promise, SystemError>>; /** * Add a monitor with no connector, which the desk extends onto and only a * capture shows: casting to a TV. A later `displays` lists it. It lasts * until removed, or until the page goes away. Fails * {@link SystemErrorKind.Other} on a desk whose monitors the engine does * not report: nested, or described by `output.displays`. See * docs/CASTING-TO-TVS.md. */ addVirtualMonitor: (mode: VirtualMonitorMode) => Promise>; /** * Hear `input.keyboard`'s keymaps and the one the desktop types on, at once * and on each switch or reload. Allowed while the desktop is locked. */ keymaps: () => Promise, SystemError>>; /** * Switch every keyboard to another of the config's keymaps, until the * desktop restarts. Fails {@link SystemErrorKind.NotFound} for a name the * config does not have. Allowed while the desktop is locked. */ selectKeymap: (choice: KeymapChoice) => Promise>; /** * Activate, deactivate or toggle the shortcuts inhibitor of the window with * the keyboard: the way back to the desktop from a VM. A window holding * none changes nothing. */ switchShortcutsInhibitor: (action: InhibitorAction) => Promise>; }; /** What {@link system} needs of the desktop `Shell` is handed. */ export type SystemHost = Pick & { addEventListener: (type: "system", listener: (event: MessageEvent) => void) => void; }; /** The system calls through `host`. Any number may share one host. */ export declare const system: (host: SystemHost) => System;