{ config, lib, pkgs, ... }: let inherit (builtins) toString isBool; inherit (lib.generators) toINI; inherit (lib.modules) mkIf; inherit (lib.options) mkOption mkEnableOption; inherit (lib.strings) escape; inherit (lib.trivial) boolToString; inherit (lib.types) str package; 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"; type = str; }; package = mkOption { description = "The GTK theme package"; default = pkgs.gruvbox-gtk-theme; type = package; }; }; iconTheme = { description = "The GTK icon theme"; name = mkOption { description = "The GTK icon theme name"; default = "Papirus"; type = str; }; package = mkOption { description = "The GTK icon theme package"; default = pkgs.papirus-icon-theme; type = package; }; }; }; 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 colloid-icon-theme ; }; variables = { GTK_THEME = cfg.theme.name; XCURSOR_THEME = "BreezeX-RosePine-Linux"; XCURSOR_SIZE = cursorSize; HYPRCURSOR_THEME = "BreezeX-RosePine-Linux"; HYPRCURSOR_SIZE = cursorSize; }; etc = let css = import ./gtk-colors.nix {inherit (config.modules.style.colorScheme) colors;}; in { "xdg/gtk-4.0/settings.ini".text = toGtk3Ini { Settings = gtkIni; }; "xdg/gtk-3.0/settings.ini".text = toGtk3Ini { Settings = gtkIni; }; "xdg/gtk-4.0/gtk.css".text = css; "xdg/gtk-3.0/gtk.css".text = css; "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 ''; }; }; }; }