+++ /dev/null
-#!/bin/sh
-
-if [ -n "$FIFO_UEBERZUG" ]; then
- printf '{"action": "remove", "identifier": "preview"}\n' >"$FIFO_UEBERZUG"
-fi
-
+++ /dev/null
-#!/bin/sh
-
-if [ -n "$FIFO_UEBERZUG" ]; then
- path="$(printf '%s' "$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' \
- "$4" "$5" "$2" "$3" "$1" >"$FIFO_UEBERZUG"
-fi
-
set info size
set sortby name
-set previewer ~/.config/lf/previewer.sh
-set cleaner ~/.config/lf/clear_img.sh
+set previewer ~/.config/lf/scripts/preview
+set cleaner ~/.config/lf/scripts/cleaner
# interpreter for shell commands
set shell sh
map ge bottom
map gs cd ~/Bilder/Screenshots
map go :fzf_jump
+map gw cd ~/Bilder/Wallpapers
# o = open
map oo push :open-with-cli<space>
+++ /dev/null
-#!/bin/sh
-
-draw() {
- ~/dotfiles/config/lf/draw_img.sh "$@"
- exit 1
-}
-
-hash() {
- printf '%s/.cache/lf/%s' "$HOME" \
- "$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
-}
-
-cache() {
- if [ -f "$1" ]; then
- draw "$@"
- fi
-}
-
-file="$1"
-shift
-
-if [ -n "$FIFO_UEBERZUG" ]; then
- case $(file -Lb --mime-type -- "$file") in
- image/*)
- orientation="$(identify -format '%[EXIF:Orientation]\n' -- "$file")"
- if [ -n "$orientation" ] && [ "$orientation" != 1 ]; then
- cache="$(hash "$file").jpg"
- cache "$cache" "$@"
- convert -- "$file" -auto-orient "$cache"
- draw "$cache" "$@"
- else
- draw "$file" "$@"
- fi
- ;;
- video/*)
- cache="$(hash "$file").jpg"
- cache "$cache" "$@"
- ffmpegthumbnailer -i "$file" -o "$cache" -s 0
- draw "$cache" "$@"
- ;;
- application/pdf)
- thumbnail="$LF_TEMPDIR/thumbnail.png"
- gs -o "$thumbnail" -sDEVICE=pngalpha -dLastPage=1 "$file" >/dev/null
- preview "$thumbnail" "$@"
- ;;
- application/tar*)
- tar tf "$file"
- ;;
- application/zip)
- unzip -l "$file"
- ;;
- application/7z)
- 7z l "$file"
- ;;
- *)
- bat -f --style plain "$file"
- ;;
- esac
-fi
-
-# shellcheck disable=SC2154
-file -Lb -- "$1" | fold -s -w "$width"
-exit 0
-
+++ /dev/null
-#!/bin/sh
-
-"$HOME/.config/ranger/scope.sh" "${1}" "${2}" "${3}" "" "" || true
-
--- /dev/null
+#!/bin/sh
+
+ueberzugpp cmd -s $UB_SOCKET -a remove -i PREVIEW
--- /dev/null
+#!/bin/sh
+
+# This is a wrapper script for lf that allows it to create image previews with
+# ueberzug. This works in concert with the lf configuration file and the
+# lf-cleaner script.
+
+set -e
+
+UB_PID=0
+UB_SOCKET=""
+
+case "$(uname -a)" in
+ *Darwin*) UEBERZUG_TMP_DIR="$TMPDIR" ;;
+ *) UEBERZUG_TMP_DIR="/tmp" ;;
+esac
+
+cleanup() {
+ exec 3>&-
+ ueberzugpp cmd -s "$UB_SOCKET" -a exit
+}
+
+if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
+ lf "$@"
+else
+ [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
+ UB_PID_FILE="$UEBERZUG_TMP_DIR/.$(uuidgen)"
+ ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE"
+ UB_PID=$(cat "$UB_PID_FILE")
+ rm "$UB_PID_FILE"
+ UB_SOCKET="$UEBERZUG_TMP_DIR/ueberzugpp-${UB_PID}.socket"
+ export UB_PID UB_SOCKET
+ trap cleanup HUP INT QUIT TERM EXIT
+ lf "$@" 3>&-
+fi
--- /dev/null
+#!/bin/sh
+
+image() {
+ 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 "$file" "$@"
+ else
+ cat "$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")" | 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 0
#!/bin/sh
+
+# This is a wrapper script for lf that allows it to create image previews with
+# ueberzug. This works in concert with the lf configuration file and the
+# lf-cleaner script.
+
set -e
-BROWSER="$(printf "qutebrowser\n--untrusted-args\n%u")"
-EDITOR="$(printf "kks\nedit")"
-VISUAL="$(printf "kks\nedit")"
-PAGER="$(printf "bat\n--style\nauto")"
+BROWSER="$(printf "qutebrowser\n--untrusted-args\n")"
+EDITOR="$(printf "kks\nedit\n")"
+VISUAL="$(printf "kks\nedit\n")"
+PAGER="$(printf "bat\n--style\nauto\n")"
-if [ -n "$DISPLAY" ]; then
- export FIFO_UEBERZUG="${TMPDIR:-/tmp}/lf-ueberzug-$$"
- cleanup() {
- exec 3>&-
- rm "$FIFO_UEBERZUG"
- }
+UB_PID=0
+UB_SOCKET=""
- mkfifo "$FIFO_UEBERZUG"
- ueberzugpp layer -s <"$FIFO_UEBERZUG" -o sixel &
- exec 3>"$FIFO_UEBERZUG"
- trap cleanup EXIT
+case "$(uname -a)" in
+ *Darwin*) UEBERZUG_TMP_DIR="$TMPDIR" ;;
+ *) UEBERZUG_TMP_DIR="/tmp" ;;
+esac
- if ! [ -d "$HOME/.cache/lf" ]; then
- mkdir -p "$HOME/.cache/lf"
- fi
+cleanup() {
+ exec 3>&-
+ ueberzugpp cmd -s "$UB_SOCKET" -a exit
+}
- /usr/bin/lf "$@" 3>&-
+if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
+ lf "$@"
else
- exec /usr/bin/lf "$@"
+ [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
+ UB_PID_FILE="$UEBERZUG_TMP_DIR/.$(uuidgen)"
+ ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE"
+ UB_PID=$(cat "$UB_PID_FILE")
+ rm "$UB_PID_FILE"
+ UB_SOCKET="$UEBERZUG_TMP_DIR/ueberzugpp-${UB_PID}.socket"
+ export UB_PID UB_SOCKET
+ trap cleanup HUP INT QUIT TERM EXIT
+ lf "$@" 3>&-
fi