diff --git a/lib/Utils/Desktop.vala b/lib/Utils/Desktop.vala index fb61a7d6..d2b3da4e 100644 --- a/lib/Utils/Desktop.vala +++ b/lib/Utils/Desktop.vala @@ -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. */ @@ -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 (); @@ -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 (); } }