Files
nix/hosts/common/user/configs/gui/gtk/default.nix
Nikolaos Karaolidis 922eb479a0 Refactor theme module
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2024-07-27 16:23:32 +01:00

81 lines
2.0 KiB
Nix

{
username ? throw "username argument is required",
}:
{
config,
lib,
pkgs,
...
}:
let
hmConfig = config.home-manager.users.${username};
in
{
home-manager.users.${username} = {
gtk = {
enable = true;
theme = {
package = pkgs.adw-gtk3;
name = "adw-gtk3-dark";
};
font = {
name = builtins.head hmConfig.theme.font.sansSerif.names;
package = builtins.head hmConfig.theme.font.sansSerif.packages;
inherit (hmConfig.theme.font) size;
};
iconTheme = {
name = builtins.head hmConfig.theme.icon.names;
package = builtins.head hmConfig.theme.icon.packages;
};
gtk2.configLocation = "${hmConfig.xdg.configHome}/gtk-2.0/gtkrc";
gtk3.extraCss = "@import './theme.css';";
gtk4.extraCss = "@import './theme.css';";
};
home = {
pointerCursor.gtk.enable = true;
file =
{
".icons/default/index.theme".enable = false;
}
// builtins.listToAttrs (
builtins.map (name: {
name = ".icons/${name}";
value.enable = false;
}) (hmConfig.theme.icon.names ++ hmConfig.theme.cursor.names)
);
};
theme.templates = {
"${hmConfig.xdg.configHome}/gtk-3.0/theme.css".source = ./theme.css;
"${hmConfig.xdg.configHome}/gtk-4.0/theme.css".source = ./theme.css;
};
theme.extraConfig = "${
lib.meta.getExe (
pkgs.writeShellApplication {
name = "theme-gtk";
runtimeInputs = with pkgs; [ dconf ];
text = ''
MODE=$(cat "${hmConfig.theme.configDir}/mode")
if [ "$MODE" = "light" ]; then
GTK_THEME="adw-gtk3"
else
GTK_THEME="adw-gtk3-dark"
fi
dconf write /org/gnome/desktop/interface/gtk-theme "'$GTK_THEME'"
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-$MODE'"
'';
}
)
} &";
};
}