nichts/modules/style/gtk.mod.nix

114 lines
3 KiB
Nix
Raw Normal View History

2024-05-22 14:29:45 +02:00
{
config,
lib,
2025-03-26 19:16:28 +01:00
pkgs,
2024-05-22 14:29:45 +02:00
...
2025-03-26 19:16:28 +01:00
}: let
2025-04-09 15:31:18 +02:00
inherit (builtins) toString isBool;
inherit (lib.generators) toINI;
inherit (lib.modules) mkIf;
2025-03-26 19:16:28 +01:00
inherit (lib.options) mkOption mkEnableOption;
2025-04-09 15:31:18 +02:00
inherit (lib.strings) escape;
inherit (lib.trivial) boolToString;
inherit (lib.types) str package;
2025-04-06 14:03:41 +02:00
cfg = config.modules.theming.gtk;
2025-04-09 15:31:18 +02:00
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";
};
2024-04-10 17:39:26 +02:00
in {
2025-04-06 14:03:41 +02:00
options.modules.theming.gtk = {
2025-03-26 19:16:28 +01:00
enable = mkEnableOption "Wether to enable GTK theming";
theme = {
name = mkOption {
description = "The GTK theme name";
2025-04-09 15:31:18 +02:00
default = "Gruvbox-Dark";
2025-03-26 19:16:28 +01:00
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";
2025-04-09 15:31:18 +02:00
default = "Papirus";
2025-03-26 19:16:28 +01:00
type = str;
};
package = mkOption {
description = "The GTK icon theme package";
2025-04-06 14:03:41 +02:00
default = pkgs.papirus-icon-theme;
2025-03-26 19:16:28 +01:00
type = package;
};
};
};
2025-04-09 15:31:18 +02:00
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
2025-04-09 15:31:18 +02:00
;
};
variables = {
GTK_THEME = cfg.theme.name;
XCURSOR_THEME = "BreezeX-RosePine-Linux";
XCURSOR_SIZE = cursorSize;
2025-04-09 15:31:18 +02:00
};
etc = let
css = import ./gtk-colors.nix {inherit (config.modules.style.colorScheme) colors;};
in {
2025-04-09 15:31:18 +02:00
"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;
2025-04-09 15:31:18 +02:00
"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
'';
2025-04-06 14:03:41 +02:00
2025-04-09 15:31:18 +02:00
"xdg/Xresources".text = ''
Xcursor.size: ${toString cursorSize}
Xcursor.theme: BreezeX-RosePine-Linux
'';
};
2025-04-06 14:03:41 +02:00
};
};
2024-04-10 17:39:26 +02:00
}