gnome-terminal: use dconf module for settings

(cherry picked from commit a0162dacf6)
This commit is contained in:
Robert Helgesson 2018-11-04 20:56:43 +01:00
parent 54fc5f778b
commit 1e7fbde1be
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -6,8 +6,6 @@ let
cfg = config.programs.gnome-terminal; cfg = config.programs.gnome-terminal;
dag = config.lib.dag;
profileColorsSubModule = types.submodule ( profileColorsSubModule = types.submodule (
{ ... }: { { ... }: {
options = { options = {
@ -91,19 +89,6 @@ let
} }
); );
toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
mkIniKeyValue = key: value:
let
tweakVal = v:
if isString v then "'${v}'"
else if isList v then "[" + concatStringsSep "," (map tweakVal v) + "]"
else if isBool v && v then "true"
else if isBool v && !v then "false"
else toString v;
in
"${key}=${tweakVal value}";
buildProfileSet = pcfg: buildProfileSet = pcfg:
{ {
visible-name = pcfg.visibleName; visible-name = pcfg.visibleName;
@ -136,25 +121,6 @@ let
) )
); );
buildIniSet = cfg:
{
"/" = {
default-show-menubar = cfg.showMenubar;
schema-version = 3;
};
}
//
{
"profiles:" = {
default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile));
list = attrNames cfg.profile;
};
}
//
mapAttrs' (name: value:
nameValuePair ("profiles:/:${name}") (buildProfileSet value)
) cfg.profile;
in in
{ {
@ -181,20 +147,23 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ pkgs.gnome3.gnome_terminal ]; home.packages = [ pkgs.gnome3.gnome_terminal ];
# The dconf service needs to be installed and prepared. dconf.settings =
home.activation.gnomeTerminal = dag.entryAfter ["installPackages"] (
let let
iniText = toDconfIni (buildIniSet cfg); dconfPath = "org/gnome/terminal/legacy";
iniFile = pkgs.writeText "gnome-terminal.ini" iniText;
dconfPath = "/org/gnome/terminal/legacy/";
in in
'' {
if [[ -v DRY_RUN ]]; then "${dconfPath}" = {
echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${iniFile} default-show-menubar = cfg.showMenubar;
else schema-version = 3;
${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${iniFile} };
fi
'' "${dconfPath}/profiles:" = {
); default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile));
list = attrNames cfg.profile;
};
}
// mapAttrs' (n: v:
nameValuePair ("${dconfPath}/profiles:/:${n}") (buildProfileSet v)
) cfg.profile;
}; };
} }