mirror of
https://github.com/nix-community/home-manager
synced 2024-11-20 10:09:45 +01:00
qutebrowser: add greasemonkey userscript option
Co-authored-by: Ivar Scholten <ivar.scholten@protonmail.com>
This commit is contained in:
parent
54c1ca74d9
commit
3433206e51
3 changed files with 71 additions and 1 deletions
|
@ -239,6 +239,28 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
greasemonkey = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [ ];
|
||||
example = literalExpression ''
|
||||
[
|
||||
(pkgs.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/afreakk/greasemonkeyscripts/1d1be041a65c251692ee082eda64d2637edf6444/youtube_sponsorblock.js";
|
||||
sha256 = "sha256-e3QgDPa3AOpPyzwvVjPQyEsSUC9goisjBUDMxLwg8ZE=";
|
||||
})
|
||||
(pkgs.writeText "some-script.js" '''
|
||||
// ==UserScript==
|
||||
// @name Some Greasemonkey script
|
||||
// ==/UserScript==
|
||||
''')
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
Greasemonkey userscripts to add to qutebrowser's {file}`greasemonkey`
|
||||
directory.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
|
@ -265,6 +287,9 @@ in {
|
|||
|
||||
quickmarksFile = optionals (cfg.quickmarks != { }) concatStringsSep "\n"
|
||||
((mapAttrsToList formatQuickmarks cfg.quickmarks));
|
||||
|
||||
greasemonkeyDir = optionals (cfg.greasemonkey != [ ]) pkgs.linkFarmFromDrvs
|
||||
"greasemonkey-userscripts" cfg.greasemonkey;
|
||||
in mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
|
@ -300,5 +325,15 @@ in {
|
|||
mkIf (cfg.quickmarks != { } && pkgs.stdenv.hostPlatform.isLinux) {
|
||||
text = quickmarksFile;
|
||||
};
|
||||
|
||||
home.file.".qutebrowser/greasemonkey" =
|
||||
mkIf (cfg.greasemonkey != [ ] && pkgs.stdenv.hostPlatform.isDarwin) {
|
||||
source = greasemonkeyDir;
|
||||
};
|
||||
|
||||
xdg.configFile."qutebrowser/greasemonkey" =
|
||||
mkIf (cfg.greasemonkey != [ ] && pkgs.stdenv.hostPlatform.isLinux) {
|
||||
source = greasemonkeyDir;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
qutebrowser-settings = ./settings.nix;
|
||||
qutebrowser-greasemonkey = ./greasemonkey.nix;
|
||||
qutebrowser-keybindings = ./keybindings.nix;
|
||||
qutebrowser-quickmarks = ./quickmarks.nix;
|
||||
qutebrowser-settings = ./settings.nix;
|
||||
}
|
||||
|
|
34
tests/modules/programs/qutebrowser/greasemonkey.nix
Normal file
34
tests/modules/programs/qutebrowser/greasemonkey.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
greasemonkeyScript = pkgs.writeText "qutebrowser-greasemonkey.js" ''
|
||||
// ==UserScript==
|
||||
// @name foo
|
||||
// @namespace foo
|
||||
// @match https://example.com/*
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
'';
|
||||
|
||||
in {
|
||||
programs.qutebrowser = {
|
||||
enable = true;
|
||||
greasemonkey = [ greasemonkeyScript ];
|
||||
};
|
||||
|
||||
test.stubs.qutebrowser = { };
|
||||
|
||||
nmt.script = let
|
||||
scriptDir = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
".qutebrowser/greasemonkey"
|
||||
else
|
||||
".config/qutebrowser/greasemonkey";
|
||||
in ''
|
||||
assertFileContent \
|
||||
home-files/${scriptDir}/qutebrowser-greasemonkey.js \
|
||||
${greasemonkeyScript}
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue