TerminalManager
TerminalManager exposes two subsystems plus helpers for opening the terminal:
Running a command
UserunInTerminal to open the terminal and execute a command directly. The command runs in a fresh session — no login shell, prompt, or MOTD, only the command’s stdout/stderr and stdin. The session’s stdin is wired to the terminal, so interactive prompts are answerable by the user:
Opening an interactive shell
UseopenTerminal to open the terminal screen. When no session is active, an interactive login shell is created automatically so the user can type commands directly:
runInTerminal:
TerminalSessionManager
Manages the lifecycle of terminal sessions. All state is exposed viaStateFlow.
Session state
Creating sessions
Getting or creating a session
Switching and terminating
TerminalSessionEntry
TerminalSessionClient
When creating a session, you provide aTerminalSessionClient callback interface. This class is defined in the terminal module (com.klyx.terminal.emulator.TerminalSessionClient), not in the klyx-api module. It receives notifications about text changes, title changes, session completion, bell events, color changes, and more.
The TerminalSessionClient interface exposes the following callbacks:
Additionally, the
terminalCursorStyle property can be set to control the cursor appearance.
TerminalSessionBinder
Manages the binding lifecycle between the app and the background terminal service.Terminal environment utilities
These functions are available in thecom.klyx.api.terminal package:
terminalEnv() sets TERM, TERM_PROGRAM, COLORTERM, HOSTNAME, TMPDIR, LANG, and LC_ALL. processEnv() configures PROOT_LOADER, PROOT_TMP_DIR, HOME, ROOTFS, PATH, and passes through relevant Android system environment variables.
Terminal paths
Terminal-specific paths are available as extensions onPaths: