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;
|
default = null;
|
||||||
description = "Default cursor theme for all GTK versions.";
|
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 {
|
config = mkIf cfg.enable {
|
||||||
|
|
|
||||||
|
|
@ -103,12 +103,14 @@ in
|
||||||
text =
|
text =
|
||||||
let
|
let
|
||||||
settings = gtkLib.mkGtkSettings {
|
settings = gtkLib.mkGtkSettings {
|
||||||
|
gtkVersion = 2;
|
||||||
inherit (cfg2)
|
inherit (cfg2)
|
||||||
font
|
font
|
||||||
theme
|
theme
|
||||||
iconTheme
|
iconTheme
|
||||||
cursorTheme
|
cursorTheme
|
||||||
;
|
;
|
||||||
|
colorScheme = null;
|
||||||
};
|
};
|
||||||
settingsText = lib.concatMapStrings (n: "${formatGtk2Option n settings.${n}}\n") (
|
settingsText = lib.concatMapStrings (n: "${formatGtk2Option n settings.${n}}\n") (
|
||||||
lib.attrNames settings
|
lib.attrNames settings
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,18 @@ in
|
||||||
description = "Cursor theme for GTK 3 applications.";
|
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 {
|
extraConfig = mkOption {
|
||||||
type =
|
type =
|
||||||
with types;
|
with types;
|
||||||
|
|
@ -112,11 +124,13 @@ in
|
||||||
text = toIni {
|
text = toIni {
|
||||||
Settings =
|
Settings =
|
||||||
gtkLib.mkGtkSettings {
|
gtkLib.mkGtkSettings {
|
||||||
|
gtkVersion = 3;
|
||||||
inherit (cfg3)
|
inherit (cfg3)
|
||||||
font
|
font
|
||||||
theme
|
theme
|
||||||
iconTheme
|
iconTheme
|
||||||
cursorTheme
|
cursorTheme
|
||||||
|
colorScheme
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
// cfg3.extraConfig;
|
// cfg3.extraConfig;
|
||||||
|
|
@ -134,11 +148,13 @@ in
|
||||||
dconf.settings."org/gnome/desktop/interface" =
|
dconf.settings."org/gnome/desktop/interface" =
|
||||||
let
|
let
|
||||||
settings = gtkLib.mkGtkSettings {
|
settings = gtkLib.mkGtkSettings {
|
||||||
|
gtkVersion = 3;
|
||||||
inherit (cfg3)
|
inherit (cfg3)
|
||||||
font
|
font
|
||||||
theme
|
theme
|
||||||
iconTheme
|
iconTheme
|
||||||
cursorTheme
|
cursorTheme
|
||||||
|
colorScheme
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
@ -148,6 +164,7 @@ in
|
||||||
"icon-theme" = settings."gtk-icon-theme-name" or null;
|
"icon-theme" = settings."gtk-icon-theme-name" or null;
|
||||||
"cursor-theme" = settings."gtk-cursor-theme-name" or null;
|
"cursor-theme" = settings."gtk-cursor-theme-name" or null;
|
||||||
"cursor-size" = settings."gtk-cursor-theme-size" 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.";
|
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 {
|
extraConfig = mkOption {
|
||||||
type =
|
type =
|
||||||
with types;
|
with types;
|
||||||
|
|
@ -105,11 +117,13 @@ in
|
||||||
text = toIni {
|
text = toIni {
|
||||||
Settings =
|
Settings =
|
||||||
gtkLib.mkGtkSettings {
|
gtkLib.mkGtkSettings {
|
||||||
|
gtkVersion = 4;
|
||||||
inherit (cfg4)
|
inherit (cfg4)
|
||||||
font
|
font
|
||||||
theme
|
theme
|
||||||
iconTheme
|
iconTheme
|
||||||
cursorTheme
|
cursorTheme
|
||||||
|
colorScheme
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
// cfg4.extraConfig;
|
// cfg4.extraConfig;
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,12 @@ in
|
||||||
# Helper function to generate the settings attribute set for a given version
|
# Helper function to generate the settings attribute set for a given version
|
||||||
mkGtkSettings =
|
mkGtkSettings =
|
||||||
{
|
{
|
||||||
|
gtkVersion,
|
||||||
font,
|
font,
|
||||||
theme,
|
theme,
|
||||||
iconTheme,
|
iconTheme,
|
||||||
cursorTheme,
|
cursorTheme,
|
||||||
|
colorScheme,
|
||||||
}:
|
}:
|
||||||
optionalAttrs (font != null) {
|
optionalAttrs (font != null) {
|
||||||
gtk-font-name =
|
gtk-font-name =
|
||||||
|
|
@ -72,7 +74,10 @@ in
|
||||||
// optionalAttrs (cursorTheme != null) { "gtk-cursor-theme-name" = cursorTheme.name; }
|
// optionalAttrs (cursorTheme != null) { "gtk-cursor-theme-name" = cursorTheme.name; }
|
||||||
// optionalAttrs (cursorTheme != null && cursorTheme.size != null) {
|
// optionalAttrs (cursorTheme != null && cursorTheme.size != null) {
|
||||||
"gtk-cursor-theme-size" = cursorTheme.size;
|
"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
|
# Package collection helper for all GTK versions
|
||||||
collectGtkPackages =
|
collectGtkPackages =
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
gtk-per-version-override = ./gtk-per-version-override.nix;
|
gtk-per-version-override = ./gtk-per-version-override.nix;
|
||||||
gtk-selective-enable = ./gtk-selective-enable.nix;
|
gtk-selective-enable = ./gtk-selective-enable.nix;
|
||||||
|
|
||||||
|
# ColorScheme tests
|
||||||
|
gtk-colorscheme = ./gtk-colorscheme.nix;
|
||||||
|
|
||||||
# GTK2
|
# GTK2
|
||||||
gtk2-basic-config = ./gtk2/gtk2-basic-config.nix;
|
gtk2-basic-config = ./gtk2/gtk2-basic-config.nix;
|
||||||
gtk2-config-file-location = ./gtk2/gtk2-config-file-location.nix;
|
gtk2-config-file-location = ./gtk2/gtk2-config-file-location.nix;
|
||||||
|
|
|
||||||
30
tests/modules/misc/gtk/gtk-colorscheme.nix
Normal file
30
tests/modules/misc/gtk/gtk-colorscheme.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
gtk = {
|
||||||
|
enable = true;
|
||||||
|
theme.name = "Adwaita";
|
||||||
|
iconTheme.name = "Adwaita";
|
||||||
|
|
||||||
|
# Global dark colorScheme
|
||||||
|
colorScheme = "dark";
|
||||||
|
|
||||||
|
# GTK3 overrides to light
|
||||||
|
gtk3.colorScheme = "light";
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
# GTK3's settings should be untouched
|
||||||
|
assertFileExists home-files/.config/gtk-3.0/settings.ini
|
||||||
|
assertFileNotRegex home-files/.config/gtk-3.0/settings.ini \
|
||||||
|
'gtk-application-prefer-dark-theme'
|
||||||
|
|
||||||
|
# GTK4 should inherit global dark colorScheme
|
||||||
|
assertFileExists home-files/.config/gtk-4.0/settings.ini
|
||||||
|
assertFileContains home-files/.config/gtk-4.0/settings.ini \
|
||||||
|
'gtk-application-prefer-dark-theme=true'
|
||||||
|
assertFileContains home-files/.config/gtk-4.0/settings.ini \
|
||||||
|
'gtk-interface-color-scheme=2'
|
||||||
|
|
||||||
|
echo "ColorScheme test completed successfully"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
[Settings]
|
[Settings]
|
||||||
|
gtk-application-prefer-dark-theme=true
|
||||||
gtk-cursor-theme-name=Adwaita
|
gtk-cursor-theme-name=Adwaita
|
||||||
gtk-cursor-theme-size=24
|
gtk-cursor-theme-size=24
|
||||||
gtk-font-name=Ubuntu 12
|
gtk-font-name=Ubuntu 12
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
[Settings]
|
[Settings]
|
||||||
|
gtk-application-prefer-dark-theme=true
|
||||||
gtk-cursor-theme-name=Adwaita
|
gtk-cursor-theme-name=Adwaita
|
||||||
gtk-cursor-theme-size=24
|
gtk-cursor-theme-size=24
|
||||||
gtk-font-name=Ubuntu 12
|
gtk-font-name=Ubuntu 12
|
||||||
gtk-icon-theme-name=Adwaita
|
gtk-icon-theme-name=Adwaita
|
||||||
|
gtk-interface-color-scheme=2
|
||||||
gtk-theme-name=Adwaita-dark
|
gtk-theme-name=Adwaita-dark
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
name = "Adwaita";
|
name = "Adwaita";
|
||||||
size = 24;
|
size = 24;
|
||||||
};
|
};
|
||||||
|
colorScheme = "dark";
|
||||||
};
|
};
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue