Crates.io | dark-light |
lib.rs | dark-light |
version | |
source | src |
created_at | 2021-02-18 19:12:09.777669+00 |
updated_at | 2025-01-10 00:03:29.641653+00 |
description | Detect if dark mode or light mode is enabled |
homepage | |
repository | https://github.com/rust-dark-light/rust-dark-light |
max_upload_size | |
id | 357180 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Supports macOS, Windows, Linux, BSDs, and WebAssembly.
On Linux the XDG Desktop Portal D-Bus API is checked for the color-scheme
preference, which works in Flatpak sandboxes without needing filesystem access.
Add to your project:
cargo add dark-light
You can detect the current mode by using the detect
function. This function returns a Mode
value.
fn main() -> Result<(), dark_light::Error> {
match dark_light::detect()? {
dark_light::Mode::Dark => println!("Dark mode"),
dark_light::Mode::Light => println!("Light mode"),
dark_light::Mode::Unspecified => println!("Unspecified"),
}
Ok(())
}
Licensed under either of the following licenses: