[go: up one dir, main page]

terminal-light 0.2.0

tells you whether your terminal is dark or light
Documentation

MIT Latest Version docs Chat on Miaou

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);