From 5e6f09795c799e5ca1f1712489ecb2a8b76e0268 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Fri, 30 Apr 2021 00:56:01 -0600 Subject: [PATCH] gtk2: allow configuration of gtkrc file Closes #519 --- modules/misc/gtk.nix | 16 +++++++++++++- tests/default.nix | 3 ++- tests/modules/misc/gtk/default.nix | 5 +++++ .../misc/gtk/gtk-basic-config-expected.conf | 1 + tests/modules/misc/gtk/gtk2-basic-config.nix | 21 +++++++++++++++++++ .../misc/gtk/gtk2-config-file-location.nix | 16 ++++++++++++++ 6 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tests/modules/misc/gtk/default.nix create mode 100644 tests/modules/misc/gtk/gtk-basic-config-expected.conf create mode 100644 tests/modules/misc/gtk/gtk2-basic-config.nix create mode 100644 tests/modules/misc/gtk/gtk2-config-file-location.nix diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index f1f83347d..cec6abd09 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -92,6 +92,18 @@ in { ~/.gtkrc-2.0. ''; }; + + configLocation = mkOption { + type = types.path; + default = "${config.home.homeDirectory}/.gtkrc-2.0"; + defaultText = + literalExample ''"''${config.home.homeDirectory}/.gtkrc-2.0"''; + example = + literalExample ''"''${config.xdg.configHome}/gtk-2.0/gtkrc"''; + description = '' + The location to put the GTK configuration file. + ''; + }; }; gtk3 = { @@ -154,10 +166,12 @@ in { home.packages = optionalPackage cfg.font ++ optionalPackage cfg.theme ++ optionalPackage cfg.iconTheme; - home.file.".gtkrc-2.0".text = + home.file.${cfg2.configLocation}.text = concatStringsSep "\n" (mapAttrsToList formatGtk2Option ini) + "\n" + cfg2.extraConfig; + home.sessionVariables.GTK2_RC_FILES = cfg2.configLocation; + xdg.configFile."gtk-3.0/settings.ini".text = toGtk3Ini { Settings = ini // cfg3.extraConfig; }; diff --git a/tests/default.nix b/tests/default.nix index fc833e29f..80589f6ed 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -86,6 +86,7 @@ import nmt { ] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ ./modules/config/i18n ./modules/misc/debug + ./modules/misc/gtk ./modules/misc/numlock ./modules/misc/pam ./modules/misc/qt @@ -106,10 +107,10 @@ import nmt { ./modules/services/fluidsynth ./modules/services/kanshi ./modules/services/lieer - ./modules/services/redshift-gammastep ./modules/services/pbgopy ./modules/services/playerctld ./modules/services/polybar + ./modules/services/redshift-gammastep ./modules/services/sxhkd ./modules/services/window-managers/i3 ./modules/services/window-managers/sway diff --git a/tests/modules/misc/gtk/default.nix b/tests/modules/misc/gtk/default.nix new file mode 100644 index 000000000..0dbae61eb --- /dev/null +++ b/tests/modules/misc/gtk/default.nix @@ -0,0 +1,5 @@ +{ + gtk2-basic-config = ./gtk2-basic-config.nix; + gtk2-config-file-location = ./gtk2-config-file-location.nix; +} + diff --git a/tests/modules/misc/gtk/gtk-basic-config-expected.conf b/tests/modules/misc/gtk/gtk-basic-config-expected.conf new file mode 100644 index 000000000..015b4a517 --- /dev/null +++ b/tests/modules/misc/gtk/gtk-basic-config-expected.conf @@ -0,0 +1 @@ +gtk-can-change-accels = 1 diff --git a/tests/modules/misc/gtk/gtk2-basic-config.nix b/tests/modules/misc/gtk/gtk2-basic-config.nix new file mode 100644 index 000000000..0302eefac --- /dev/null +++ b/tests/modules/misc/gtk/gtk2-basic-config.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + gtk = { + enable = true; + gtk2.extraConfig = "gtk-can-change-accels = 1"; + }; + + nmt.script = '' + assertFileExists home-files/.gtkrc-2.0 + assertFileContents home-files/.gtkrc-2.0 ${ + ./gtk-basic-config-expected.conf + } + assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ + 'GTK2_RC_FILES=.*/.gtkrc-2.0' + ''; + }; +} diff --git a/tests/modules/misc/gtk/gtk2-config-file-location.nix b/tests/modules/misc/gtk/gtk2-config-file-location.nix new file mode 100644 index 000000000..41de2877f --- /dev/null +++ b/tests/modules/misc/gtk/gtk2-config-file-location.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + gtk.enable = true; + gtk.gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; + + nmt.script = '' + assertFileExists home-files/.config/gtk-2.0/gtkrc + assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ + 'GTK2_RC_FILES=.*/\.config/gtk-2.0/gtkrc' + ''; + }; +}