diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-11-24 20:14:43 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-11-24 20:14:43 +0100 |
commit | 118e70dd7493f781175143b7ba4b7f335ba8b69a (patch) | |
tree | 9fe900e1020b037cd67de54516bee7f04523b7b7 | |
parent | docs(todo): Integrate into taskwarrior as tasks (diff) | |
download | nixos-config-118e70dd7493f781175143b7ba4b7f335ba8b69a.tar.gz nixos-config-118e70dd7493f781175143b7ba4b7f335ba8b69a.zip |
fix(modules/lf/ctpv): Improve ctpv config file generation
-rw-r--r-- | modules/by-name/lf/lf/ctpv/default.nix | 59 |
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 ]; }; |