mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
Qutebrowser: Way to define settings for each domain
This commit adds a way to define per-domain settings in config.py. The option is called domainSettings and contains an attribute set of attribute sets with the base domain as the name.
This commit is contained in:
parent
2f3367769a
commit
6d2711f813
4 changed files with 79 additions and 13 deletions
0
.nvimlog
Normal file
0
.nvimlog
Normal file
|
@ -6,10 +6,8 @@ let
|
||||||
|
|
||||||
cfg = config.programs.qutebrowser;
|
cfg = config.programs.qutebrowser;
|
||||||
|
|
||||||
formatLine = o: n: v:
|
|
||||||
let
|
|
||||||
formatValue = v:
|
formatValue = v:
|
||||||
if builtins.isNull v then
|
if v == null then
|
||||||
"None"
|
"None"
|
||||||
else if builtins.isBool v then
|
else if builtins.isBool v then
|
||||||
(if v then "True" else "False")
|
(if v then "True" else "False")
|
||||||
|
@ -19,13 +17,25 @@ let
|
||||||
"[${concatStringsSep ", " (map formatValue v)}]"
|
"[${concatStringsSep ", " (map formatValue v)}]"
|
||||||
else
|
else
|
||||||
builtins.toString v;
|
builtins.toString v;
|
||||||
in if builtins.isAttrs v then
|
|
||||||
|
formatLine = o: n: v:
|
||||||
|
if builtins.isAttrs v then
|
||||||
concatStringsSep "\n" (mapAttrsToList (formatLine "${o}${n}.") v)
|
concatStringsSep "\n" (mapAttrsToList (formatLine "${o}${n}.") v)
|
||||||
else
|
else
|
||||||
"${o}${n} = ${formatValue v}";
|
"${o}${n} = ${formatValue v}";
|
||||||
|
|
||||||
formatDictLine = o: n: v: ''${o}['${n}'] = "${v}"'';
|
formatDictLine = o: n: v: ''${o}['${n}'] = "${v}"'';
|
||||||
|
|
||||||
|
formatDomainBlock = n: v:
|
||||||
|
let
|
||||||
|
formatDomainLine = d: o: on: ov:
|
||||||
|
if builtins.isAttrs ov then
|
||||||
|
concatStringsSep "\n"
|
||||||
|
(mapAttrsToList (formatDomainLine d "${o}${on}.") ov)
|
||||||
|
else
|
||||||
|
''config.set("${o}${on}", ${formatValue ov}, "${d}")'';
|
||||||
|
in concatStringsSep "\n" (mapAttrsToList (formatDomainLine n "") v);
|
||||||
|
|
||||||
formatKeyBindings = m: b:
|
formatKeyBindings = m: b:
|
||||||
let
|
let
|
||||||
formatKeyBinding = m: k: c:
|
formatKeyBinding = m: k: c:
|
||||||
|
@ -109,6 +119,26 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
domainSettings = mkOption {
|
||||||
|
type = types.attrsOf (types.attrsOf types.anything);
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Per-domain options to add to qutebrowser {file}`config.py` file.
|
||||||
|
See <https://qutebrowser.org/doc/help/settings.html>
|
||||||
|
for options.
|
||||||
|
'';
|
||||||
|
example = literalExpression ''
|
||||||
|
{
|
||||||
|
"https://netflix.com" = {
|
||||||
|
content.notifications.enable = false;
|
||||||
|
};
|
||||||
|
"https://facebook.com" = {
|
||||||
|
content.notifications.enable = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
keyMappings = mkOption {
|
keyMappings = mkOption {
|
||||||
type = types.attrsOf types.str;
|
type = types.attrsOf types.str;
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -277,6 +307,7 @@ in {
|
||||||
else
|
else
|
||||||
"config.load_autoconfig(False)")
|
"config.load_autoconfig(False)")
|
||||||
] ++ mapAttrsToList (formatLine "c.") cfg.settings
|
] ++ mapAttrsToList (formatLine "c.") cfg.settings
|
||||||
|
++ mapAttrsToList formatDomainBlock cfg.domainSettings
|
||||||
++ mapAttrsToList (formatDictLine "c.aliases") cfg.aliases
|
++ mapAttrsToList (formatDictLine "c.aliases") cfg.aliases
|
||||||
++ mapAttrsToList (formatDictLine "c.url.searchengines") cfg.searchEngines
|
++ mapAttrsToList (formatDictLine "c.url.searchengines") cfg.searchEngines
|
||||||
++ mapAttrsToList (formatDictLine "c.bindings.key_mappings")
|
++ mapAttrsToList (formatDictLine "c.bindings.key_mappings")
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
qutebrowser-keybindings = ./keybindings.nix;
|
qutebrowser-keybindings = ./keybindings.nix;
|
||||||
qutebrowser-quickmarks = ./quickmarks.nix;
|
qutebrowser-quickmarks = ./quickmarks.nix;
|
||||||
qutebrowser-settings = ./settings.nix;
|
qutebrowser-settings = ./settings.nix;
|
||||||
|
qutebrowser-domainsettings = ./domainsettings.nix;
|
||||||
}
|
}
|
||||||
|
|
34
tests/modules/programs/qutebrowser/domainsettings.nix
Normal file
34
tests/modules/programs/qutebrowser/domainsettings.nix
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.qutebrowser = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
domainSettings = {
|
||||||
|
"https://teams.microsoft.com".content.notifications.enabled = true;
|
||||||
|
"https://www.netflix.com".content.notifications.enabled = false;
|
||||||
|
"https://www.facebook.com".content.notifications.enabled = false;
|
||||||
|
"https://mail.google.com".content.register_protocol_handler = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.qutebrowser = { };
|
||||||
|
|
||||||
|
nmt.script = let
|
||||||
|
qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
".qutebrowser/config.py"
|
||||||
|
else
|
||||||
|
".config/qutebrowser/config.py";
|
||||||
|
in ''
|
||||||
|
assertFileContent \
|
||||||
|
home-files/${qutebrowserConfig} \
|
||||||
|
${
|
||||||
|
pkgs.writeText "qutebrowser-expected-config.py" ''
|
||||||
|
config.load_autoconfig(False)
|
||||||
|
config.set("content.register_protocol_handler", True, "https://mail.google.com")
|
||||||
|
config.set("content.notifications.enabled", True, "https://teams.microsoft.com")
|
||||||
|
config.set("content.notifications.enabled", False, "https://www.facebook.com")
|
||||||
|
config.set("content.notifications.enabled", False, "https://www.netflix.com")''
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue