aboutsummaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorawy <awy@tutamail.com>2024-08-07 14:46:39 +0300
committerawy <awy@tutamail.com>2024-08-07 14:46:39 +0300
commite768595362435aa26936e25c39c58b2c38fcb4d3 (patch)
tree5cef8a2de36a04b570b9476da0d7e094760ca151 /.config
parente82d74fa8de7ed165869674027832523318e9246 (diff)
lf
Diffstat (limited to '.config')
-rwxr-xr-x.config/lf/cleaner4
-rw-r--r--.config/lf/lfrc14
-rwxr-xr-x.config/lf/scope28
3 files changed, 46 insertions, 0 deletions
diff --git a/.config/lf/cleaner b/.config/lf/cleaner
new file mode 100755
index 0000000..08dd4e8
--- /dev/null
+++ b/.config/lf/cleaner
@@ -0,0 +1,4 @@
+#!/bin/sh
+rm ~/.cache/lf/* -f
+exec kitty +kitten icat --clear --stdin no --silent --transfer-mode file </dev/null >/dev/tty
+
diff --git a/.config/lf/lfrc b/.config/lf/lfrc
new file mode 100644
index 0000000..2be3b1c
--- /dev/null
+++ b/.config/lf/lfrc
@@ -0,0 +1,14 @@
+set sixel true
+set cleaner ~/.config/lf/cleaner
+set previewer ~/.config/lf/scope
+
+cmd delete ${{
+ clear; tput cup $(($(tput lines)/3)); tput bold
+ set -f
+ printf "%s\n\t" "$fx"
+ printf "delete?[y/N]"
+ read ans
+ [ $ans = "y" ] && rm -rf -- $fx
+}}
+
+map D delete
diff --git a/.config/lf/scope b/.config/lf/scope
new file mode 100755
index 0000000..bb9f1f6
--- /dev/null
+++ b/.config/lf/scope
@@ -0,0 +1,28 @@
+#!/bin/sh
+draw() {
+ kitty +kitten icat --silent --stdin no --transfer-mode file --place "${w}x${h}@${x}x${y}" "$1" </dev/null >/dev/tty
+ exit 1
+}
+
+file="$1"
+w="$2"
+h="$3"
+x="$4"
+y="$5"
+
+case "$(file -Lb --mime-type "$file")" in
+ image/*)
+ draw "$file"
+ ;;
+ video/*)
+ # vidthumb is from here:
+ # https://raw.githubusercontent.com/duganchen/kitty-pistol-previewer/main/vidthumb
+ CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
+ [ ! -f "$CACHE" ] && ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0
+ draw "$CACHE"
+ #draw "$(vidthumb "$file")"
+ ;;
+ text/* | */xml | application/json | application/x-ndjson) bat -p --theme ansi --terminal-width "$(($4-2))" -f "$1" ;;
+esac
+
+pistol "$file"lace "${2}x${3}@${4}x${5}" "$1"