From 03374732adf4cb387733e5cca525ed80758f5f60 Mon Sep 17 00:00:00 2001 From: Bloxx12 Date: Wed, 9 Apr 2025 15:31:18 +0200 Subject: [PATCH] style: cleanup gtk theming --- modules/style/gtk.nix | 92 +++++++++++++++++++++++++++++---------- modules/style/theming.nix | 58 ++---------------------- 2 files changed, 72 insertions(+), 78 deletions(-) diff --git a/modules/style/gtk.nix b/modules/style/gtk.nix index 2e180bc..3a09c87 100644 --- a/modules/style/gtk.nix +++ b/modules/style/gtk.nix @@ -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 + ''; + }; }; }; - }; } diff --git a/modules/style/theming.nix b/modules/style/theming.nix index d276442..11be807 100644 --- a/modules/style/theming.nix +++ b/modules/style/theming.nix @@ -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 [ + ]; }