added lf config

This commit is contained in:
Jakub 2024-07-23 09:43:55 -04:00
parent cce170ad96
commit 56130f51e8
5 changed files with 259 additions and 0 deletions

10
user/.config/lf/cleaner Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
#!/usr/bin/env sh
cat <<EOF | paste -sd '' >"$LF_UEBERZUG_TEMPDIR/fifo"
{
"action": "remove",
"identifier": "lf-preview"
}
EOF

160
user/.config/lf/icons Executable file
View File

@ -0,0 +1,160 @@
tw 
st 
ow 
dt 
di 
fi 
ln 
or 
ex 
*.c 
*.cc 
*.clj 
*.coffee 
*.cpp 
*.css 
*.d 
*.dart 
*.erl 
*.exs 
*.fs 
*.go 
*.h 
*.hh 
*.hpp 
*.hs 
*.html 
*.java 
*.jl 
*.js 
*.json 
*.lua 
*.md 
*.php 
*.pl 
*.pro 
*.py 
*.rb 
*.rs 
*.scala 
*.ts 
*.vim 
*.cmd 
*.ps1 
*.sh 
*.bash 
*.zsh 
*.fish 
*.tar 
*.tgz 
*.arc 
*.arj 
*.taz 
*.lha 
*.lz4 
*.lzh 
*.lzma 
*.tlz 
*.txz 
*.tzo 
*.t7z 
*.zip 
*.z 
*.dz 
*.gz 
*.lrz 
*.lz 
*.lzo 
*.xz 
*.zst 
*.tzst 
*.bz2 
*.bz 
*.tbz 
*.tbz2 
*.tz 
*.deb 
*.rpm 
*.jar 
*.war 
*.ear 
*.sar 
*.rar 
*.alz 
*.ace 
*.zoo 
*.cpio 
*.7z 
*.rz 
*.cab 
*.wim 
*.swm 
*.dwm 
*.esd 
*.jpg 
*.jpeg 
*.mjpg 
*.mjpeg 
*.gif 
*.bmp 
*.pbm 
*.pgm 
*.ppm 
*.tga 
*.xbm 
*.xpm 
*.tif 
*.tiff 
*.png 
*.svg 
*.svgz 
*.mng 
*.pcx 
*.mov 
*.mpg 
*.mpeg 
*.m2v 
*.mkv 
*.webm 
*.ogm 
*.mp4 
*.m4v 
*.mp4v 
*.vob 
*.qt 
*.nuv 
*.wmv 
*.asf 
*.rm 
*.rmvb 
*.flc 
*.avi 
*.fli 
*.flv 
*.gl 
*.dl 
*.xcf 
*.xwd 
*.yuv 
*.cgm 
*.emf 
*.ogv 
*.ogx 
*.aac 
*.au 
*.flac 
*.m4a 
*.mid 
*.midi 
*.mka 
*.mp3 
*.mpc 
*.ogg 
*.ra 
*.wav 
*.oga 
*.opus 
*.spx 
*.xspf 
*.pdf 
*.nix 

20
user/.config/lf/lfrc Executable file
View File

@ -0,0 +1,20 @@
set scrolloff 8
set icons
set hidden
set autoquit
set ratios 1:1
set cleaner "~/.config/lf/cleaner"
set previewer "~/.config/lf/previewer"
cmd quit-and-cd &{{
pwd > $LF_CD_FILE
lf -remote "send $id quit"
}}
cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')"
map D delete
map q quit-and-cd
map Y $printf "%s" "$fx" | xclip -selection clipboard

45
user/.config/lf/previewer Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
#!/usr/bin/env sh
preview() {
cat <<-EOF | paste -sd '' >"$LF_UEBERZUG_TEMPDIR/fifo"
{
"action": "add", "identifier": "lf-preview",
"path": "$1", "x": $4, "y": $5, "width": $2, "height": $3,
"scaler": "contain"
}
EOF
}
file="$1"; shift
case "$(basename "$file" | tr '[:upper:]' '[:lower:]')" in
*.tar*) tar tf "$file" ;;
*.zip) unzip -l "$file" ;;
*.rar) unrar l "$file" ;;
*.7z) 7z l "$file" ;;
*.avi|*.mp4|*.mkv)
thumbnail="$LF_UEBERZUG_TEMPDIR/thumbnail.png"
ffmpeg -y -i "$file" -vframes 1 "$thumbnail"
preview "$thumbnail" "$@"
;;
*.pdf)
thumbnail="$LF_UEBERZUG_TEMPDIR/thumbnail.png"
gs -o "$thumbnail" -sDEVICE=pngalpha -dLastPage=1 "$file" >/dev/null
preview "$thumbnail" "$@"
;;
*.jpg|*.jpeg|*.png|*.bmp)
preview "$file" "$@" ;;
*.svg)
thumbnail="$LF_UEBERZUG_TEMPDIR/thumbnail.png"
gm convert "$file" "$thumbnail"
preview "$thumbnail" "$@"
;;
*.gif)
thumbnail="$LF_UEBERZUG_TEMPDIR/thumbnail.png"
gm convert "$file[0]" "$thumbnail"
preview "$thumbnail" "$@"
;;
*) cat "$file" ;;
esac
return 127 # nonzero retcode required for lf previews to reload

24
user/.local/bin/lf-run Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env zsh
cleanup() {
~/.config/lf/cleaner
kill "$UEBERZUGPID"
pkill -f "tail -f $LF_UEBERZUG_TEMPDIR/fifo"
rm -rf "$LF_UEBERZUG_TEMPDIR"
}
trap cleanup INT HUP
# Set up temporary directory.
export LF_UEBERZUG_TEMPDIR="$(mktemp -d -t lf-ueberzug-XXXXXX)"
# Launch ueberzug.
mkfifo "$LF_UEBERZUG_TEMPDIR/fifo"
tail -f "$LF_UEBERZUG_TEMPDIR/fifo" | ueberzug layer --silent &
UEBERZUGPID=$!
# Add this script's directory to PATH so that the lf config will find
# lf-ueberzug-cleaner and lf-ueberzgu-previewer. If no startup directory is
# provided, start lf in the examples directory.
export PATH="$PATH:${ZSH_ARGZERO:A:h}"
/usr/bin/lf
cleanup