Apply
Synopsis
Section titled “Synopsis”tman apply (--dark | --light) [--fallback-theme <name>]apply is deliberately non-interactive. It is the command intended for theme daemons, desktop appearance hooks, scheduled jobs, and other automation.
Options
Section titled “Options”| Flag | Behavior |
|---|---|
-d, --dark | Apply the active theme’s dark variant. |
-l, --light | Apply the active theme’s light variant. |
--fallback-theme <name> | Theme family to apply and save when ~/.tg.json has no activeTheme. |
Exactly one mode is required. Supplying neither or both is an error.
TMAN_FALLBACK_THEME=<name> is the environment equivalent of --fallback-theme. The flag wins when both are set; an empty variable counts as unset.
State contract
Section titled “State contract”apply reads activeTheme from ~/.tg.json and never changes an existing value. If no active theme exists and no fallback is configured, it exits nonzero, explains that ~/.tg.json was missing or had no activeTheme, and points at tman select, --fallback-theme, and TMAN_FALLBACK_THEME.
This separation is intentional: select changes theme identity; apply changes only the active family’s mode. Automation therefore cannot accidentally choose a stale light-specific or dark-specific theme.
Unattended use and fallback recovery
Section titled “Unattended use and fallback recovery”A daemon has nobody to notice when ~/.tg.json disappears, so configure a fallback in its hook. Precedence is persisted activeTheme > --fallback-theme > TMAN_FALLBACK_THEME, and the fallback is used only when activeTheme is absent. When it is used, apply:
- validates the name and requires generated light and dark artifacts for at least one applicable target, the same rule
selectuses; - warns
activeTheme missing from ~/.tg.json; recovering with fallback '<name>'; - applies the fallback and, only after at least one target applied it, saves it as
activeThemeso later runs need no fallback. A failed save is a warning; the theme is already live and the next run recovers the same way.
Exit codes
Section titled “Exit codes”apply exits 0 when at least one adapter applied the theme; failed adapters are logged but do not fail a partial apply. It exits nonzero when the mode flags are wrong, when there is no active theme and no fallback, when the fallback name is invalid or lacks generated artifacts, or when no adapter applied the theme. The published launcher propagates this status, and a signal-killed CLI is never reported as success.
Examples
Section titled “Examples”# One-time user choicetman select --theme material --dark
# Safe for repeated automationtman apply --lighttman apply --dark
# Daemon/hook form that survives a lost ~/.tg.jsonTMAN_FALLBACK_THEME=material tman apply --darkApplication still uses the same adapter pipeline as select: adapters run in registry order, failures are isolated, and at least one adapter must actually apply for the command to succeed.