Skip to content

Commit

Permalink
Dark Mode Strength stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce authored Jan 2, 2023
1 parent d743f68 commit 713ff3d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/Utils/Desktop.vala
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,45 @@ public class He.Desktop : Object {
prefers_color_scheme = ColorScheme.NO_PREFERENCE;
}

/**
* The dark mode strength preference enum, which is used to determine the dark mode strength of the desktop.
*/
public enum DarkModeStrength {
MEDIUM,
HARSH,
SOFT
}

/**
* The color scheme preference.
*/
private DarkModeStrength? _dark_mode_strength = null;
public DarkModeStrength dark_mode_strength {
get {
return _dark_mode_strength;
}
private set {
_dark_mode_strength = value;
}
}

private void setup_dark_mode_strength () {
try {
portal = Portal.Settings.get ();

dark_mode_strength = (DarkModeStrength) portal.read (
"org.freedesktop.appearance",
"dark-mode-strength"
).get_variant ().get_uint32 ();

return;
} catch (Error e) {
debug ("%s", e.message);
}

dark_mode_strength = DarkModeStrength.MEDIUM;
}

/**
* The accent color preference.
*/
Expand Down Expand Up @@ -141,6 +180,10 @@ public class He.Desktop : Object {

accent_color = rgb_color;
}

if (scheme == "org.freedesktop.appearance" && key == "dark-mode-strength") {
dark_mode_strength = (DarkModeStrength) val.get_uint32 ();
}

if (scheme == "org.freedesktop.appearance" && key == "color-scheme") {
prefers_color_scheme = (ColorScheme) val.get_uint32 ();
Expand All @@ -151,6 +194,7 @@ public class He.Desktop : Object {
construct {
setup_prefers_color_scheme ();
setup_accent_color ();
setup_dark_mode_strength ();
init_handle_settings_change ();
}
}

0 comments on commit 713ff3d

Please sign in to comment.