mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
gtk: add color scheme option
This commit is contained in:
parent
ea3fe2bd72
commit
f35703b412
10 changed files with 87 additions and 1 deletions
|
|
@ -73,6 +73,17 @@ in
|
|||
default = null;
|
||||
description = "Default cursor theme for all GTK versions.";
|
||||
};
|
||||
|
||||
colorScheme = mkOption {
|
||||
type = types.nullOr (
|
||||
types.enum [
|
||||
"dark"
|
||||
"light"
|
||||
]
|
||||
);
|
||||
default = null;
|
||||
description = "Default color scheme for all GTK versions";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
|
|
|||
|
|
@ -103,12 +103,14 @@ in
|
|||
text =
|
||||
let
|
||||
settings = gtkLib.mkGtkSettings {
|
||||
gtkVersion = 2;
|
||||
inherit (cfg2)
|
||||
font
|
||||
theme
|
||||
iconTheme
|
||||
cursorTheme
|
||||
;
|
||||
colorScheme = null;
|
||||
};
|
||||
settingsText = lib.concatMapStrings (n: "${formatGtk2Option n settings.${n}}\n") (
|
||||
lib.attrNames settings
|
||||
|
|
|
|||
|
|
@ -76,6 +76,18 @@ in
|
|||
description = "Cursor theme for GTK 3 applications.";
|
||||
};
|
||||
|
||||
colorScheme = mkOption {
|
||||
type = types.nullOr (
|
||||
types.enum [
|
||||
"dark"
|
||||
"light"
|
||||
]
|
||||
);
|
||||
default = cfg.colorScheme;
|
||||
defaultText = literalExpression "config.gtk.colorScheme";
|
||||
description = "Color scheme for GTK 3 applications.";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type =
|
||||
with types;
|
||||
|
|
@ -112,11 +124,13 @@ in
|
|||
text = toIni {
|
||||
Settings =
|
||||
gtkLib.mkGtkSettings {
|
||||
gtkVersion = 3;
|
||||
inherit (cfg3)
|
||||
font
|
||||
theme
|
||||
iconTheme
|
||||
cursorTheme
|
||||
colorScheme
|
||||
;
|
||||
}
|
||||
// cfg3.extraConfig;
|
||||
|
|
@ -134,11 +148,13 @@ in
|
|||
dconf.settings."org/gnome/desktop/interface" =
|
||||
let
|
||||
settings = gtkLib.mkGtkSettings {
|
||||
gtkVersion = 3;
|
||||
inherit (cfg3)
|
||||
font
|
||||
theme
|
||||
iconTheme
|
||||
cursorTheme
|
||||
colorScheme
|
||||
;
|
||||
};
|
||||
in
|
||||
|
|
@ -148,6 +164,7 @@ in
|
|||
"icon-theme" = settings."gtk-icon-theme-name" or null;
|
||||
"cursor-theme" = settings."gtk-cursor-theme-name" or null;
|
||||
"cursor-size" = settings."gtk-cursor-theme-size" or null;
|
||||
"color-scheme" = if cfg3.colorScheme != null then "prefer-${cfg3.colorScheme}" else null;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,18 @@ in
|
|||
description = "Cursor theme for GTK 4 applications.";
|
||||
};
|
||||
|
||||
colorScheme = mkOption {
|
||||
type = types.nullOr (
|
||||
types.enum [
|
||||
"dark"
|
||||
"light"
|
||||
]
|
||||
);
|
||||
default = cfg.colorScheme;
|
||||
defaultText = literalExpression "config.gtk.colorScheme";
|
||||
description = "Color scheme for GTK 4 applications.";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type =
|
||||
with types;
|
||||
|
|
@ -105,11 +117,13 @@ in
|
|||
text = toIni {
|
||||
Settings =
|
||||
gtkLib.mkGtkSettings {
|
||||
gtkVersion = 4;
|
||||
inherit (cfg4)
|
||||
font
|
||||
theme
|
||||
iconTheme
|
||||
cursorTheme
|
||||
colorScheme
|
||||
;
|
||||
}
|
||||
// cfg4.extraConfig;
|
||||
|
|
|
|||
|
|
@ -55,10 +55,12 @@ in
|
|||
# Helper function to generate the settings attribute set for a given version
|
||||
mkGtkSettings =
|
||||
{
|
||||
gtkVersion,
|
||||
font,
|
||||
theme,
|
||||
iconTheme,
|
||||
cursorTheme,
|
||||
colorScheme,
|
||||
}:
|
||||
optionalAttrs (font != null) {
|
||||
gtk-font-name =
|
||||
|
|
@ -72,7 +74,10 @@ in
|
|||
// optionalAttrs (cursorTheme != null) { "gtk-cursor-theme-name" = cursorTheme.name; }
|
||||
// optionalAttrs (cursorTheme != null && cursorTheme.size != null) {
|
||||
"gtk-cursor-theme-size" = cursorTheme.size;
|
||||
};
|
||||
}
|
||||
// optionalAttrs (colorScheme == "dark") { "gtk-application-prefer-dark-theme" = true; }
|
||||
// optionalAttrs (gtkVersion == 4 && colorScheme == "dark") { "gtk-interface-color-scheme" = 2; }
|
||||
// optionalAttrs (gtkVersion == 4 && colorScheme == "light") { "gtk-interface-color-scheme" = 3; };
|
||||
|
||||
# Package collection helper for all GTK versions
|
||||
collectGtkPackages =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue