This commit is contained in:
array-in-a-matrix 2023-08-10 12:19:23 -04:00
parent c89247e212
commit f7ffa4de41
4 changed files with 19 additions and 10 deletions

View file

@ -1,12 +1,8 @@
#!/bin/sh
image() {
if [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG"
exit 1
else
chafa "$1" -s "$4x"
fi
geometry="$(($2-2))x$3"
chafa "$1" -f sixel -s "$geometry" --animate false
}
batorcat() {
@ -20,6 +16,17 @@ batorcat() {
fi
}
glowormdcat() {
file="$1"
shift
if command -v glow > /dev/null 2>&1
then
glow "$file"
else
mdcat "$file"
fi
}
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 "$(printf "%s\n" "$(readlink -f "$1")" | awk '{print tolower($0)}')" in
@ -29,7 +36,8 @@ case "$(printf "%s\n" "$(readlink -f "$1")" | awk '{print tolower($0)}')" in
*.tar) tar tf "$1" ;;
*.zip|*.jar|*.war|*.ear|*.oxt) unzip -l "$1" ;;
*.rar) unrar l "$1" ;;
*.md) glow -s dark "$1" ;;
*.md)
glowormdcat "$1";;
*.7z) 7z l "$1" ;;
*.[1-8]) man "$1" | col -b ;;
*.o) nm "$1";;
@ -37,7 +45,7 @@ case "$(printf "%s\n" "$(readlink -f "$1")" | awk '{print tolower($0)}')" in
*.iso) iso-info --no-header -l "$1" ;;
*.odt|*.ods|*.odp|*.sxw) odt2txt "$1" ;;
*.doc) catdoc "$1" ;;
*.docx) docx2txt "$1" - ;;
*.docx) docx2txt "$1" ;;
*.xml|*.html) w3m -dump "$1";;
*.xls|*.xlsx)
ssconvert --export-type=Gnumeric_stf:stf_csv "$1" "fd://1" | batorcat --language=csv
@ -65,7 +73,7 @@ case "$(printf "%s\n" "$(readlink -f "$1")" | awk '{print tolower($0)}')" in
ffmpegthumbnailer -i "$1" -o "${CACHE}.jpg" -s 0 -q 5
image "${CACHE}.jpg" "$2" "$3" "$4" "$5"
;;
*.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp|*.gif|*.jfif)
*.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp|*.tiff|*.gif|*.jfif|*.ico)
image "$1" "$2" "$3" "$4" "$5"
;;
*.svg)

View file

@ -1,4 +1,3 @@
set ratios 1:2:3
set previewer ~/.config/lf/preview
set cleaner ~/.config/lf/cleaner
set drawbox true

View file

@ -1,2 +1,3 @@
--sub-auto=all
--sub-file-paths=sub:subtitles:Subs
save-position-on-quit

View file

@ -11,6 +11,7 @@ alias uptime="uptime --pretty"
# simple aliases
alias vi="vim"
alias vim="nvim"
alias tree="tree -a"
alias ip="ip -c"
alias py="python3"
alias open="xdg-open"