Your friendly neighbourhood whale crate for reading various system-level
accessibility and UI preferences across platforms 🐋
The following preferences are supported:
- [
AccentColor]—The user's current system wide accent color preference. - [
ColorScheme]—The user's preference for either light or dark mode. - [
Contrast]—The user's preferred contrast level. - [
ReducedMotion]—The user's reduced motion preference. - [
ReducedTransparency]—The user's reduced transparency preference.
Example
The easiest way to get the preferences is to use the
[Preferences::stream] function to create a stream that is continually
updated when things change:
use mundy::{Preferences, Interest};
use futures_util::StreamExt as _;
// Interest tells mundy which preferences it should monitor for you.
// use `Interest::All` if you're interested in all preferences.
let mut stream = Preferences::stream(Interest::AccentColor);
# let _ = async move {
while let Some(preferences) = stream.next().await {
eprintln!("accent color: {:?}", preferences.accent_color);
}
# };
Alternatively, there's [Preferences::subscribe] which
accepts a simple callback function instead.
«I believe in a universe that doesn't care and people
who do. [...] but this whale is pretty cool. ― Angus