Skip to content

Commit

Permalink
Added Default variant (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
edfloreshz committed Dec 25, 2022
1 parent 115982f commit d87d9be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/freedesktop.rs
Expand Up @@ -90,7 +90,7 @@ pub fn detect() -> Mode {
DesktopEnvironment::Gnome => detect_gtk("/org/gnome/desktop/interface/gtk-theme"),
DesktopEnvironment::Mate => detect_gtk("/org/mate/desktop/interface/gtk-theme"),
DesktopEnvironment::Unity => detect_gtk("/org/gnome/desktop/interface/gtk-theme"),
_ => Mode::Light,
_ => Mode::Default,
},
}
}
2 changes: 2 additions & 0 deletions src/lib.rs
Expand Up @@ -8,6 +8,7 @@
//! match mode {
//! dark_light::Mode::Dark => {},
//! dark_light::Mode::Light => {},
//! dark_light::Mode::Default => {},
//! }
//! ```

Expand Down Expand Up @@ -63,6 +64,7 @@ mod platform {
pub enum Mode {
Dark,
Light,
Default,
}

impl Mode {
Expand Down
16 changes: 7 additions & 9 deletions src/windows.rs
@@ -1,17 +1,15 @@
use crate::Mode;
use winreg::RegKey;

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

pub fn detect() -> Mode {
let hkcu = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
if let Ok(subkey) =
hkcu.open_subkey("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize")
{
if let Ok(dword) = subkey.get_value::<u32, _>("AppsUseLightTheme") {
Mode::from(dword == 0)
} else {
Mode::Light
if let Ok(subkey) = hkcu.open_subkey(SUBKEY) {
if let Ok(dword) = subkey.get_value::<u32, _>(VALUE) {
return Mode::from(dword == 0);
}
} else {
Mode::Light
}
Mode::Light
}

0 comments on commit d87d9be

Please sign in to comment.