Crates.io | dark-light |
lib.rs | dark-light |
version | 1.1.1 |
source | src |
created_at | 2021-02-18 19:12:09.777669 |
updated_at | 2024-04-04 05:05:02.978036 |
description | Detect if dark mode or light mode is enabled |
homepage | |
repository | https://github.com/frewsxcv/rust-dark-light |
max_upload_size | |
id | 357180 |
size | 48,103 |
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.
fn main() {
let mode = dark_light::detect();
match mode {
// Dark mode
dark_light::Mode::Dark => {},
// Light mode
dark_light::Mode::Light => {},
// Unspecified
dark_light::Mode::Default => {},
}
}
cargo run --example detect
Licensed under either of
at your option.