aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/lf
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/lf')
-rw-r--r--modules/by-name/lf/lf/ctpv/default.nix59
1 files changed, 51 insertions, 8 deletions
diff --git a/modules/by-name/lf/lf/ctpv/default.nix b/modules/by-name/lf/lf/ctpv/default.nix
index 9667bc48..29f4f8ba 100644
--- a/modules/by-name/lf/lf/ctpv/default.nix
+++ b/modules/by-name/lf/lf/ctpv/default.nix
@@ -19,7 +19,37 @@
}
+ "/bin/${name}";
+ default_previews = [
+ "any"
+ "atool"
+ "audio"
+ "bat"
+ "cat"
+ "colordiff"
+ "delta"
+ "diff_so_fancy"
+ "elinks"
+ "font"
+ "glow"
+ "gpg"
+ "highlight"
+ "image"
+ "jq"
+ "libreoffice"
+ "ls"
+ "lynx"
+ "mdcat"
+ "pdf"
+ "source_highlight"
+ "svg"
+ "symlink"
+ "torrent"
+ "video"
+ "w3m"
+ ];
+
mkPreview = name: {
+ escape ? true,
mime_matches ? [],
extension_matches ? [],
priority ? 0,
@@ -34,17 +64,28 @@
assert builtins.length split == 2; ''"${rhs}"/"${lhs}"'';
extensions = lib.strings.concatStringsSep " " (builtins.map (val: ''."${val}"'') extension_matches);
- mimes = lib.strings.concatStringsSep " " (builtins.map mkMimePath mime_matches);
+ mimes = lib.strings.concatStringsSep " " (
+ if escape
+ then
+ builtins.map mkMimePath mime_matches
+ else mime_matches
+ );
function = functionCall {
inherit name dependencies;
replacementStrings = {HELPERS = ./helpers.sh;} // replacementStrings;
};
- in ''
- preview ${name} ${extensions} ${mimes} {{
- ${function}
- }}
- priority ${name} ${builtins.toString priority}
- '';
+ in
+ lib.optionalString (builtins.elem name default_previews) "remove ${name}\n"
+ + ''
+ preview ${name} ${extensions} ${mimes} {{
+ ${function}
+
+ # Always exit with success, when the function didn't exit,
+ # to ensure that error messages come through
+ true
+ }}
+ priority ${name} ${builtins.toString priority}
+ '';
mkRemove = name: ''
remove ${name}
@@ -72,10 +113,12 @@ in
"w3m" = null;
any = {
+ escape = false;
+ mime_matches = ["*/*"];
priority = -1;
dependencies = [
pkgs.exiftool
- pkgs.vim # For xxd
+ pkgs.tinyxxd # For xxd
];
};