dark_light/platforms/
windows.rs

1
2
3
4
5
6
7
8
9
10
11
12
use crate::{Error, Mode};
use winreg::RegKey;

const SUBKEY: &str = "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
const VALUE: &str = "AppsUseLightTheme";

pub fn detect() -> Result<Mode, Error> {
    let hkcu = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
    let subkey = hkcu.open_subkey(SUBKEY)?;
    let dword: u32 = subkey.get_value(VALUE)?;
    Ok((dword == 0).into())
}