style: cleanup gtk theming

This commit is contained in:
Bloxx12 2025-04-09 15:31:18 +02:00
commit 03374732ad
2 changed files with 72 additions and 78 deletions

View file

@ -4,18 +4,43 @@
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (builtins) toString isBool;
inherit (lib.generators) toINI;
inherit (lib.modules) mkMerge mkIf;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str package;
inherit (lib.strings) escape;
inherit (lib.trivial) boolToString;
cfg = config.modules.theming.gtk;
toGtk3Ini = toINI {
mkKeyValue = key: value: let
value' =
if isBool value
then boolToString value
else toString value;
in "${escape ["="] key}=${value'}";
};
gtkIni = {
gtk-application-prefer-dark-theme = 1;
gtk-font-name = "Lexend 11";
gtk-icon-theme-name = "Papirus";
gtk-xft-antialias = 1;
gtk-xft-hinting = 1;
gtk-xft-hintstyle = "hintslight";
gtk-xft-rgba = "rgb";
gtk-cursor-theme-name = "BreezeX-RosePine-Linux";
gtk-theme-name = "Gruvbox-Dark";
};
in {
options.modules.theming.gtk = {
enable = mkEnableOption "Wether to enable GTK theming";
theme = {
name = mkOption {
description = "The GTK theme name";
default = "Gruvbox-Dark-BL";
default = "Gruvbox-Dark";
type = str;
};
package = mkOption {
@ -28,7 +53,7 @@ in {
description = "The GTK icon theme";
name = mkOption {
description = "The GTK icon theme name";
default = "Papirus-Dark";
default = "Papirus";
type = str;
};
package = mkOption {
@ -38,28 +63,49 @@ in {
};
};
};
config = mkIf cfg.enable {
# NOTE: we need this or gtk breaks
programs.dconf.enable = true;
config = let
cursorSize = 32;
in
mkIf cfg.enable {
programs.dconf.enable = true;
environment = {
systemPackages = builtins.attrValues {
inherit
(pkgs)
rose-pine-cursor
gruvbox-gtk-theme
papirus-icon-theme
;
};
variables = {
GTK_THEME = cfg.theme.name;
XCURSOR_THEME = "BreezeX-RosePine-Linux";
XCURSOR_SIZE = toString cursorSize;
environment = {
systemPackages = builtins.attrValues {
inherit
(pkgs)
gruvbox-gtk-theme
papirus-icon-theme
;
};
variables = let
cursorSize = 32;
in {
GTK_THEME = "Gruvbox-Dark";
XCURSOR_THEME = "BreezeX-RosePine-Linux";
XCURSOR_SIZE = cursorSize;
HYPRCURSOR_THEME = "BreezeX-RosePine-Linux";
HYPRCURSOR_SIZE = toString cursorSize;
};
etc = {
"xdg/gtk-4.0/settings.ini".text = toGtk3Ini {
Settings = gtkIni;
};
"xdg/gtk-3.0/settings.ini".text = toGtk3Ini {
Settings = gtkIni;
};
HYPRCURSOR_THEME = "BreezeX-RosePine-Linux";
HYPRCURSOR_SIZE = cursorSize;
"xdg/gtk-2.0/gtkrc".text = ''
gtk-cursor-theme-name = BreezeX-RosePine-Linux
gtk-cursor-theme-size = ${toString cursorSize}
gtk-theme-name = ${cfg.theme.name}
gtk-icon-theme-name = ${cfg.iconTheme.name}
gtk-font-name = Lexend 11
'';
"xdg/Xresources".text = ''
Xcursor.size: ${toString cursorSize}
Xcursor.theme: BreezeX-RosePine-Linux
'';
};
};
};
};
}

View file

@ -4,67 +4,15 @@
pkgs,
...
}: let
inherit (builtins) toString isBool;
inherit (lib.generators) toINI;
inherit (lib.modules) mkMerge mkIf;
inherit (lib.options) mkEnableOption;
inherit (lib.strings) escape;
inherit (lib.trivial) boolToString;
cfg = config.modules.theming;
toGtk3Ini = toINI {
mkKeyValue = key: value: let
value' =
if isBool value
then boolToString value
else toString value;
in "${escape ["="] key}=${value'}";
};
gtkIni = {
gtk-application-prefer-dark-theme = 1;
gtk-font-name = "Lexend 11";
gtk-icon-theme-name = "Papirus-Dark";
gtk-xft-antialias = 1;
gtk-xft-hinting = 1;
gtk-xft-hintstyle = "hintslight";
gtk-xft-rgba = "rgb";
gtk-cursor-theme-name = "BreezeX-RosePine-Linux";
gtk-theme-name = "Gruvbox-Dark";
};
in {
options.modules.theming = {
qt.enable = mkEnableOption "qt theming";
};
config = mkMerge [
(mkIf cfg.gtk.enable {
environment = {
systemPackages = builtins.attrValues {
inherit (pkgs) rose-pine-cursor;
};
etc = {
"xdg/gtk-4.0/settings.ini".text = toGtk3Ini {
Settings = gtkIni;
};
"xdg/gtk-3.0/settings.ini".text = toGtk3Ini {
Settings = gtkIni;
};
"xdg/gtk-2.0/gtkrc".text = ''
gtk-cursor-theme-name = BreezeX-RosePine-Linux
gtk-cursor-theme-size = 32
gtk-theme-name = Gruvbox-Dark
gtk-icon-theme-name = Papirus-Dark
gtk-font-name = Lexend 11
'';
"xdg/Xresources".text = ''
Xcursor.size: 32
Xcursor.theme: BreezeX-RosePine-Linux
'';
};
};
})
];
config =
mkMerge [
];
}