This commit is contained in:
whoami 2025-03-23 22:24:32 +01:00
commit 01a9e86575
64 changed files with 2284 additions and 0 deletions

5
config/lf/bookmarks Normal file
View file

@ -0,0 +1,5 @@
/mnt/
/mnt/disk/anime
/tmp
~/
~/.config

4
config/lf/bookmarks.sh Normal file
View file

@ -0,0 +1,4 @@
#!/bin/sh
x=$(cat ~/.config/lf/bookmarks | fzf)
echo $x

2
config/lf/cleaner Normal file
View file

@ -0,0 +1,2 @@
#!/bin/sh
[ -n "$FIFO_UEBERZUG" ] && printf '{"action":"remove","identifier":"preview"}\n' >"$FIFO_UEBERZUG"

37
config/lf/lfrc Normal file
View file

@ -0,0 +1,37 @@
set previewer ~/.config/lf/previewer
set cleaner ~/.config/lf/cleaner
set sortby time
set info time
set reverse true
set period 1
map D delete
map H set hidden!
map I sxivT
map b bookmarks
map m mkdir
cmd bookmarks ${{
x=$(~/.config/lf/bookmarks.sh)
lf -remote "send cd $x"
}}
cmd mkdir ${{
printf "mkdir: "; read x; mkdir $x
}}
cmd open ${{
case $(file --mime-type "$f" -bL) in
text/*|json) $EDITOR "$f" ;;
video/* | audio/*) echo "Playing: $f"; mpv "$f" ;;
audio/* | audio/*) echo "Playing: $f"; mpv "$f" ;;
image/*) sxiv -a "$f" & ;;
*) xdg-open "$f" ;;
esac
}}
cmd sxivT ${{
cd $PWD
sxiv -t .
}}

55
config/lf/previewer Normal file
View file

@ -0,0 +1,55 @@
#!/bin/sh
draw() {
path="$(readlink -f -- "$1" | sed 's/\\/\\\\/g;s/"/\\"/g')"
printf '{"action":"add","identifier":"preview","x":%d,"y":%d,"width":%d,"height":%d,"scaler":"contain","scaling_position_x":0.5,"scaling_position_y":0.5,"path":"%s"}\n' \
"$x" "$y" "$width" "$height" "$path" >"$FIFO_UEBERZUG"
exit 1
}
hash() {
cache="$HOME/.cache/lf/$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f -- "$1")" | sha256sum | cut -d' ' -f1).jpg"
}
cache() {
if ! [ -f "$cache" ]; then
dir="$(dirname -- "$cache")"
[ -d "$dir" ] || mkdir -p -- "$dir"
"$@"
fi
draw "$cache"
}
file="$1"
width="$2"
height="$3"
x="$4"
y="$5"
case "$(file -Lb --mime-type -- "$file")" in
image/*)
if [ -n "$FIFO_UEBERZUG" ]; then
# ueberzug doesn't handle image orientation correctly
orientation="$(magick identify -format '%[orientation]\n' -- "$file")"
if [ -n "$orientation" ] \
&& [ "$orientation" != Undefined ] \
&& [ "$orientation" != TopLeft ]; then
hash "$file"
cache magick -- "$file" -auto-orient "$cache"
else
draw "$file"
fi
fi
;;
video/*)
if [ -n "$FIFO_UEBERZUG" ]; then
hash "$file"
cache ffmpegthumbnailer -i "$file" -o "$cache" -s 0
fi
;;
text/*)
exec cat "$file"
;;
esac
file -Lb -- "$file" | fold -s -w "$width"
exit 0