terminal-light
This crate answers the question "Is the terminal dark or light?".
It provides either
- the background color as RGB
- the background color's luma, which varies from 0 (black) to 1 (white)
A use case in a TUI is to determine what set of colors would be more suitable depending on the terminal's background:
let should_use_light_skin = terminal_light::luma()
.map_or(false, |luma| luma > 0.6);