theme/
theme.rs

1//! This example shows how to detect if the terminal uses
2//! a dark-on-light or a light-on-dark theme.
3
4use terminal_colorsaurus::{color_palette, Error, QueryOptions, ThemeMode};
5
6fn main() -> Result<(), display::DisplayAsDebug<Error>> {
7    let colors = color_palette(QueryOptions::default())?;
8
9    let theme = match colors.theme_mode() {
10        ThemeMode::Dark => "dark",
11        ThemeMode::Light => "light",
12    };
13
14    println!(
15        "{theme}, fg: {}, bg: {}",
16        colors.foreground.perceived_lightness(),
17        colors.background.perceived_lightness()
18    );
19
20    Ok(())
21}
22
23#[path = "../examples-utils/display.rs"]
24mod display;