Skip to main content
rb.system reads the state of the computer a script runs on: the clock, the cursor position, the screen size and the focused window. It also runs commands and types text through the operating system. A script reaches for it to check which app has focus, call a command-line tool, or enter text. Needs: the exec permission for exec and exec_detached. This script runs git status on F5 and logs its error output when the command exits with a nonzero code:

rb.system.exec

Runs cmd through the shell (cmd.exe /C on Windows, sh -c on macOS) and waits for it.
  • options.timeout: milliseconds, default 5000. On expiry the process is killed (on macOS its whole process group) and the call raises exec timed out after <ms>ms.
  • options.cwd: working directory.
  • stdout and stderr keep the first 64 KB (65,536 bytes) each, with trailing whitespace trimmed. exit is -1 when the process has no exit code.
  • On Windows no console window appears.
Inside a coroutine the command runs on a worker thread and the coroutine yields. Elsewhere it blocks the engine until the command ends and logs one warning per script; that fallback is deprecated. Without the exec permission the call raises System.Exec() requires 'exec' permission and Rebind stops the script.

rb.system.exec_detached

Starts cmd directly, without a shell, and returns its process id at once. options.args is a list of arguments, passed as given; options.cwd sets the working directory. Output is discarded and the process keeps running after the script stops. A failed start raises exec detached spawn failed: <reason>.

rb.system.type_text

Types text through the host operating system and never through the script’s HID output, so it types the same in hardware mode. That includes any Unicode. It raises when the operating system refuses the input, for example macOS without the Accessibility grant.