hunger / rust-dark-light

Rust crate to detect if dark mode or light mode is enabled

Home Page:https://crates.io/crates/dark-light

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rust-dark-light

Rust crate to detect if dark mode or light mode is enabled. Supports macOS, Windows, Linux, BSDs, and WASM. On Linux and BSDs, first the XDG Desktop Portal dbus API is checked for the color-scheme preference, which works in Flatpak sandboxes without needing filesystem access. If that does not work, fallback methods are used for KDE, GNOME, Cinnamon, MATE, XFCE, and Unity.

API Documentation

Usage

fn main() {
    let mode = dark_light::detect();

    match mode {
        dark_light::Mode::Dark => {},
        dark_light::Mode::Light => {},
    }
}

Example

cargo run --example detect

About

Rust crate to detect if dark mode or light mode is enabled

https://crates.io/crates/dark-light


Languages

Language:Rust 100.0%