Skip to content

Apply

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.

FlagBehavior
-d, --darkApply the active theme’s dark variant.
-l, --lightApply 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.

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.

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:

  1. validates the name and requires generated light and dark artifacts for at least one applicable target, the same rule select uses;
  2. warns activeTheme missing from ~/.tg.json; recovering with fallback '<name>';
  3. applies the fallback and, only after at least one target applied it, saves it as activeTheme so later runs need no fallback. A failed save is a warning; the theme is already live and the next run recovers the same way.

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.

Terminal window
# One-time user choice
tman select --theme material --dark
# Safe for repeated automation
tman apply --light
tman apply --dark
# Daemon/hook form that survives a lost ~/.tg.json
TMAN_FALLBACK_THEME=material tman apply --dark

Application 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.