dark_light/platforms/
windows.rs

1use crate::{Error, Mode};
2use winreg::RegKey;
3
4const SUBKEY: &str = "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
5const VALUE: &str = "AppsUseLightTheme";
6
7pub fn detect() -> Result<Mode, Error> {
8    let hkcu = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
9    let subkey = hkcu.open_subkey(SUBKEY)?;
10    let dword: u32 = subkey.get_value(VALUE)?;
11    Ok((dword == 0).into())
12}