1
0
Fork 0

improve mimetype detection in lf previews

This commit is contained in:
Luca Bilke 2024-01-23 22:53:10 +01:00
parent 00e2732589
commit f7302fa83e
1 changed files with 4 additions and 6 deletions

View File

@ -40,7 +40,8 @@ batorcat() {
}
run() {
if ! command -v $1 >/dev/null 2>&1; then
#shellcheck disable=SC2068
if ! command -v "$1" >/dev/null 2>&1; then
printf "%b" "${RED}Cannot execute $1${RESET}"
exit 1
elif $@; then
@ -53,7 +54,8 @@ run() {
CACHE="$HOME/.cache/lf/thumbnail-$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
case "$(xdg-mime query filetype "$1")" in
# We set the desktop to gnome to force usage of `gio` over `file` for better detection
case "$(env XDG_CURRENT_DESKTOP=GNOME xdg-mime query filetype "$1")" in
*/x-bzip-compressed-tar | */x-compressed-tar | */x-xz-compressed-tar) run als -- "$1" ;;
*/x-7z-compressed | */vnd.rar | */x-tar | */zip | */x-java-archive | */x-xz) run 7z l "$1" | sed 1,11d ;;
*/x-cd-image) run iso-info --no-header -l "$1" ;;
@ -85,10 +87,6 @@ text/* | */json | */schema+json | */xml | */javascript) batorcat "$1" "$2" ;;
;;
esac
case "$(file -bL --mime-type "$1")" in
text/*) batorcat "$1" "$2" ;;
esac
xdg-mime query filetype "$1"
mediainfo "$1"