summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornic <ra@afu.re>2025-04-14 10:58:34 -0400
committernic <ra@afu.re>2025-04-14 10:58:34 -0400
commit54f0e0af8b2cd7dc687a6bf44a9df45b6f5f8776 (patch)
tree32e9e5b661ada0d3109fb4d1587a433e80ecb11f
parentc110abe7e04f8c4c717fe23a1b6fb5f606dad5e4 (diff)
update lf config + switch ueberzug to ueberzugpp
-rwxr-xr-x.config/lf/cleaner5
-rw-r--r--.config/lf/icons3
-rw-r--r--.config/lf/lfrc22
-rwxr-xr-x.config/lf/scope108
-rw-r--r--.config/lf/shortcutrc27
5 files changed, 101 insertions, 64 deletions
diff --git a/.config/lf/cleaner b/.config/lf/cleaner
index a184d84..0159d5a 100755
--- a/.config/lf/cleaner
+++ b/.config/lf/cleaner
@@ -1,4 +1,3 @@
#!/bin/sh
-if [ -n "$FIFO_UEBERZUG" ]; then
- printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG"
-fi
+
+ueberzugpp cmd -s $UB_SOCKET -a remove -i PREVIEW
diff --git a/.config/lf/icons b/.config/lf/icons
index 0ce4114..6be18d1 100644
--- a/.config/lf/icons
+++ b/.config/lf/icons
@@ -76,3 +76,6 @@ ex 🎯
*.torrent 🔽
*.jar ♨
*.java ♨
+*.sl3 ⛁
+*.db ⛁
+*.sql ⛁
diff --git a/.config/lf/lfrc b/.config/lf/lfrc
index b7f7b1b..4b790a1 100644
--- a/.config/lf/lfrc
+++ b/.config/lf/lfrc
@@ -1,8 +1,4 @@
-# Note on Image Previews
-# For those wanting image previews, like this system, there are four steps to
-# set it up. These are done automatically for LARBS users, but I will state
-# them here for others doing it manually.
-#
+# IMAGE PREVIEW
# 1. ueberzug must be installed.
# 2. The scope file (~/.config/lf/scope for me), must have a command similar to
# mine to generate ueberzug images.
@@ -11,6 +7,7 @@
# that creates the environment for ueberzug. This command can be be aliased
# in your shellrc (`alias lf="lfub") or if set to a binding, should be
# called directly instead of normal lf.
+# called directly instead of normal lf.
# Basic vars
set shellopts '-eu'
@@ -24,12 +21,10 @@ set previewer '~/.config/lf/scope'
set autoquit true
# cmds/functions
-#
-# Replace excel for visidata...
cmd open ${{
case $(file --mime-type "$(readlink -f $f)" -b) in
- #application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) excel ;;
- image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
+ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) vd $fx ;;
+ image/vnd.djvu|application/pdf|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
image/svg+xml) display -- $f ;;
@@ -44,8 +39,13 @@ cmd open ${{
video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
application/pgp-encrypted) $EDITOR $fx ;;
- #application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) excel $fx;;
- *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
+ application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f libreoffice $fx >/dev/null 2>&1 ;;
+ application/octet-stream) case ${f##*.} in
+ doc|docx|xls|xlsx|odt|ppt|pptx) setsid -f libreoffice $fx >/dev/null 2>&1 ;;
+ ts) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
+ *) setsid -f zathura $fx >/dev/null 2>&1 ;;
+ esac ;;
+ *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
esac
}}
diff --git a/.config/lf/scope b/.config/lf/scope
index 8265a87..971b8c9 100755
--- a/.config/lf/scope
+++ b/.config/lf/scope
@@ -1,57 +1,65 @@
#!/bin/sh
-# File preview handler for lf.
-
-set -C -f
-IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"
-
image() {
- if [ -f "$1" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1; 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"
- else
- mediainfo "$6"
- fi
+ FILE_PATH="$1"
+ X=$4
+ Y=$5
+ MW=$(($2 - 1))
+ MH=$3
+ ueberzugpp cmd -s "$UB_SOCKET" -a add -i PREVIEW -x "$X" -y "$Y" --max-width "$MW" --max-height "$MH" -f "$FILE_PATH"
+ exit 1
+}
+
+batorcat() {
+ file="$1"
+ shift
+ if command -v bat >/dev/null 2>&1; then
+ bat --color=always --style=plain --pager=never --theme=ansi "$file" "$@"
+ else
+ cat "$file"
+ fi
}
-# Note that the cache file name is a function of file information, meaning if
-# an image appears in multiple places across the machine, it will not have to
-# be regenerated once seen.
+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 "$(file --dereference --brief --mime-type -- "$1")" in
- image/avif) 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" ] && convert "$1" "$CACHE.jpg"
- image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;;
- image/vnd.djvu)
- 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" ] && djvused "$1" -e 'select 1; save-page-with /dev/stdout' | convert -density 200 - "$CACHE.jpg" > /dev/null 2>&1
- image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;;
-image/svg+xml)
- 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" ] && inkscape --convert-dpi-method=none -o "$CACHE.png" --export-overwrite -D --export-png-color-mode=RGBA_16 "$1"
- image "$CACHE.png" "$2" "$3" "$4" "$5" "$1"
- ;;
- image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;;
- text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;;
- text/troff) man ./ "$1" | col -b ;;
- text/* | */xml | application/json | application/x-ndjson) bat -p --theme ansi --terminal-width "$(($4-2))" -f "$1" ;;
- audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;;
- video/* )
- 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
- image "$CACHE" "$2" "$3" "$4" "$5" "$1"
- ;;
- */pdf)
- 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.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
- image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
- ;;
- */epub+zip|*/mobi*)
- 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.jpg" ] && gnome-epub-thumbnailer "$1" "$CACHE.jpg"
- image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
- ;;
- application/*zip) atool --list -- "$1" ;;
- *opendocument*) odt2txt "$1" ;;
- application/pgp-encrypted) gpg -d -- "$1" ;;
+case "$(printf "%s\n" "$(readlink -f "$1")" | tr '[:upper:]' '[:lower:]')" in
+ *.tgz | *.tar.gz) tar tzf "$1" ;;
+ *.tar.bz2 | *.tbz2) tar tjf "$1" ;;
+ *.tar.txz | *.txz) xz --list "$1" ;;
+ *.tar) tar tf "$1" ;;
+ *.zip | *.jar | *.war | *.ear | *.oxt) unzip -l "$1" ;;
+ *.rar) unrar l "$1" ;;
+ *.7z) 7z l "$1" ;;
+ *.[1-8]) man "$1" | col -b ;;
+ *.o) nm "$1" ;;
+ *.torrent) transmission-show "$1" ;;
+ *.iso) iso-info --no-header -l "$1" ;;
+ *.odt | *.ods | *.odp | *.sxw) odt2txt "$1" ;;
+ *.doc) catdoc "$1" ;;
+ *.docx) docx2txt "$1" - ;;
+ *.xls | *.xlsx)
+ ssconvert --export-type=Gnumeric_stf:stf_csv "$1" "fd://1" | batorcat --language=csv
+ ;;
+ *.wav | *.mp3 | *.flac | *.m4a | *.wma | *.ape | *.ac3 | *.og[agx] | *.spx | *.opus | *.as[fx] | *.mka)
+ exiftool "$1"
+ ;;
+ *.pdf)
+ [ ! -f "${CACHE}.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
+ image "${CACHE}.jpg" "$2" "$3" "$4" "$5"
+ ;;
+ *.avi | *.mp4 | *.wmv | *.dat | *.3gp | *.ogv | *.mkv | *.mpg | *.mpeg | *.vob | *.fl[icv] | *.m2v | *.mov | *.webm | *.ts | *.mts | *.m4v | *.r[am] | *.qt | *.divx)
+ [ ! -f "${CACHE}.jpg" ] && 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)
+ image "$1" "$2" "$3" "$4" "$5"
+ ;;
+ *.svg)
+ [ ! -f "${CACHE}.jpg" ] && convert "$1" "${CACHE}.jpg"
+ image "${CACHE}.jpg" "$2" "$3" "$4" "$5"
+ ;;
+ *)
+ batorcat "$1"
+ ;;
esac
-exit 1
+exit 0
diff --git a/.config/lf/shortcutrc b/.config/lf/shortcutrc
new file mode 100644
index 0000000..6900073
--- /dev/null
+++ b/.config/lf/shortcutrc
@@ -0,0 +1,27 @@
+map Ccac cd "/home/nic/.cache"
+map Ccf cd "/home/nic/.config"
+map CD cd "/home/nic/Downloads"
+map Cd cd "/home/nic/Documents"
+map Cdt cd "/home/nic/.local/share"
+map Ch cd "/home/nic"
+map Cm cd "/home/nic/Music"
+map Cmn cd "/mnt"
+map Cpp cd "/home/nic/Pictures"
+map Csc cd "/home/nic/.local/bin"
+map Csrc cd "/home/nic/.local/src"
+map Cvv cd "/home/nic/Videos"
+map Ebf $$EDITOR "/home/nic/.config/shell/bm-files"
+map Ebd $$EDITOR "/home/nic/.config/shell/bm-dirs"
+map Ecfx $$EDITOR "/home/nic/.config/x11/xresources"
+map Ecfv $$EDITOR "/home/nic/.config/nvim/init.vim"
+map Ecfz $$EDITOR "/home/nic/.config/zsh/.zshrc"
+map Ecfa $$EDITOR "/home/nic/.config/shell/aliasrc"
+map Ecfp $$EDITOR "/home/nic/.config/shell/profile"
+map Ecfm $$EDITOR "/home/nic/.config/mutt/muttrc"
+map Ecfn $$EDITOR "/home/nic/.config/newsboat/config"
+map Ecfu $$EDITOR "/home/nic/.config/newsboat/urls"
+map Ecfmb $$EDITOR "/home/nic/.config/ncmpcpp/bindings"
+map Ecfmc $$EDITOR "/home/nic/.config/ncmpcpp/config"
+map Ecfl $$EDITOR "/home/nic/.config/lf/lfrc"
+map EcfL $$EDITOR "/home/nic/.config/lf/scope"
+map EcfX $$EDITOR "/home/nic/.config/nsxiv/exec/key-handler"