Skip to content
Alex Pasmantier edited this page Jan 7, 2025 · 7 revisions

Dynamically Update Theme (light/dark mode)

Television has both UI and syntax themes that need to be updated. One way to update those themes via scripting is to reference an "adaptive" theme in the television config and change the symlink to those theme files.

~/.config/television/config.toml

[ui]
theme = "adaptive"

[previewers.file]
theme = "adaptive"

Add a script that can change the adaptive themes to dark themes...

ln -s -f ~/.config/bat/themes/CatppuccinMocha.tmTheme ~/.config/bat/themes/adaptive.tmTheme;
ln -s -f ~/.config/television/themes/catppuccin-mocha.toml ~/.config/television/themes/adaptive.toml;
bat cache --build

...and the light would just do the opposite...

ln -s -f ~/.config/bat/themes/CatppuccinMocha.tmTheme ~/.config/bat/themes/adaptive.tmTheme;
ln -s -f ~/.config/television/themes/catppuccin-mocha.toml ~/.config/television/themes/adaptive.toml;
bat cache --build

In the video below I've got a script named toggle_theme that, among other things, updates these symlinks and changes my terminal's (Wezterm) theme. I typically kick this script off from within an editor so I don't see that logging.

2025-01-02T200820.mp4
Clone this wiki locally