File: main.rs

package info (click to toggle)
rust-terminal-light 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 184 kB
  • sloc: makefile: 2
file content (21 lines) | stat: -rw-r--r-- 600 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! Run this with
//!     cargo run --example dark-or-light

fn main() {
    println!();
    match terminal_light::luma() {
        Ok(luma) if luma > 0.85 => {
            println!(" You're using a light theme (luma={})", luma);
        }
        Ok(luma) if luma < 0.2 => {
            println!(" You're using a dark theme (luma={})", luma);
        }
        Ok(luma) => {
            println!(" You're using a kind of intermediate theme (luma={})", luma);
        }
        Err(e) => {
            println!(" I couldn't determine the background's luma: {}", e);
        }
    }
    println!();
}