diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/by-name/lf/lf/ctpv/default.nix | 18 | ||||
-rw-r--r-- | modules/by-name/lf/lf/ctpv/helpers.sh | 13 | ||||
-rw-r--r-- | modules/by-name/lf/lf/ctpv/prev/any.sh | 2 | ||||
-rw-r--r-- | modules/by-name/lf/lf/ctpv/prev/audio.sh | 4 | ||||
-rw-r--r-- | modules/by-name/lf/lf/ctpv/prev/glow.sh | 2 | ||||
-rw-r--r-- | modules/by-name/lf/lf/ctpv/prev/gpg.sh | 2 |
6 files changed, 33 insertions, 8 deletions
diff --git a/modules/by-name/lf/lf/ctpv/default.nix b/modules/by-name/lf/lf/ctpv/default.nix index 29f4f8ba..b47e03bd 100644 --- a/modules/by-name/lf/lf/ctpv/default.nix +++ b/modules/by-name/lf/lf/ctpv/default.nix @@ -14,7 +14,19 @@ inherit name; src = ./prev/${name}.sh; keepPath = false; - dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash coreutils;}); + dependencies = + dependencies + ++ ( + with pkgs; [ + dash + coreutils + # Dependencies of the helpers.sh script + chafa + gnused + gnugrep + unixtools.script + ] + ); inherit replacementStrings; } + "/bin/${name}"; @@ -66,8 +78,7 @@ extensions = lib.strings.concatStringsSep " " (builtins.map (val: ''."${val}"'') extension_matches); mimes = lib.strings.concatStringsSep " " ( if escape - then - builtins.map mkMimePath mime_matches + then builtins.map mkMimePath mime_matches else mime_matches ); function = functionCall { @@ -162,7 +173,6 @@ in image = { mime_matches = ["image/*"]; dependencies = [ - pkgs.chafa ]; }; diff --git a/modules/by-name/lf/lf/ctpv/helpers.sh b/modules/by-name/lf/lf/ctpv/helpers.sh index 50a0e7cd..379a98a4 100644 --- a/modules/by-name/lf/lf/ctpv/helpers.sh +++ b/modules/by-name/lf/lf/ctpv/helpers.sh @@ -54,3 +54,16 @@ convert_and_show_image() { isBinary() { LC_ALL=C LC_MESSAGES=C grep --with-filename --max-count=1 '^' "$1" 2>&1 | grep --quiet 'binary file matches$' } + +hide_script_env() { + cmd="" + for part in "$@"; do + if [ "$cmd" = "" ]; then + cmd="'$part'" + else + cmd="$cmd '$part'" + fi + done + + script --command "$cmd" --quiet --return /dev/null +} diff --git a/modules/by-name/lf/lf/ctpv/prev/any.sh b/modules/by-name/lf/lf/ctpv/prev/any.sh index 7209fccb..bb25d90b 100644 --- a/modules/by-name/lf/lf/ctpv/prev/any.sh +++ b/modules/by-name/lf/lf/ctpv/prev/any.sh @@ -54,5 +54,5 @@ if exiftool "$f" >/dev/null 2>&1; then exiftool -- "$f" else # `exiftool` did not recognize the file. - xxd -- "$f" + hide_script_env xxd -- "$f" fi diff --git a/modules/by-name/lf/lf/ctpv/prev/audio.sh b/modules/by-name/lf/lf/ctpv/prev/audio.sh index a828ab6c..c5abc646 100644 --- a/modules/by-name/lf/lf/ctpv/prev/audio.sh +++ b/modules/by-name/lf/lf/ctpv/prev/audio.sh @@ -11,10 +11,10 @@ cache_f="$cache_f" . %HELPERS audio() { - ffmpegthumbnailer "-i$f" -s0 -q5 -t10 "-o$cache_f" 2>/dev/null + ffmpegthumbnailer -i "$f" -s 0 -q 5 -t 10 -o "$cache_f" 2>/dev/null } -x="$(ffmpeg -hide_banner "-i$f" 2>&1)" +x="$(ffmpeg -hide_banner -i "$f" 2>&1)" printf '%s\n' "$x" y=$((y + $(printf '%s\n' "$x" | wc -l))) diff --git a/modules/by-name/lf/lf/ctpv/prev/glow.sh b/modules/by-name/lf/lf/ctpv/prev/glow.sh index c77bfa41..301fe675 100644 --- a/modules/by-name/lf/lf/ctpv/prev/glow.sh +++ b/modules/by-name/lf/lf/ctpv/prev/glow.sh @@ -12,4 +12,6 @@ w="$w" # Specify the style, to force `glow` to output colors. # tracking issue: https://github.com/charmbracelet/glow/issues/654 +# We can't use `hide_script_env` because of some bespoke reason. (It just forces glow to +# run for ever and then return garbage) glow --style dark --width "$w" "$f" diff --git a/modules/by-name/lf/lf/ctpv/prev/gpg.sh b/modules/by-name/lf/lf/ctpv/prev/gpg.sh index 72cca3a6..f162c565 100644 --- a/modules/by-name/lf/lf/ctpv/prev/gpg.sh +++ b/modules/by-name/lf/lf/ctpv/prev/gpg.sh @@ -10,4 +10,4 @@ w="$w" . %HELPERS -sq inspect -- "$f" 2>&1 +hide_script_env sq inspect -- "$f" |