termbg

Detect terminal background color and determine light/dark theme

brewmacoslinux
Try with needOr install directly
Source

About

Rust library for terminal background color detection

Commands

termbg

Examples

Detect if terminal has light or dark background$ termbg
Get RGB values of terminal background color$ termbg -v
Use termbg in a script to conditionally set theme$ if termbg | grep -q dark; then echo 'Dark mode'; fi