dark-light 0.2.0

Detect if dark mode or light mode is enabled
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::Mode;
use std::process;

pub fn detect() -> Mode {
    if let Ok(output) = process::Command::new("defaults")
        .arg("read")
        .arg("-g")
        .arg("AppleInterfaceStyle")
        .output()
    {
        Mode::from(output.stdout.starts_with(b"Dark"))
    } else {
        Mode::Light
    }
}