diff options
Diffstat (limited to 'dotfiles/system/.config/lf')
| -rwxr-xr-x | dotfiles/system/.config/lf/cleaner | 4 | ||||
| -rwxr-xr-x | dotfiles/system/.config/lf/draw_img | 67 | ||||
| -rwxr-xr-x | dotfiles/system/.config/lf/image | 18 | ||||
| -rw-r--r-- | dotfiles/system/.config/lf/lfrc | 333 | ||||
| -rwxr-xr-x | dotfiles/system/.config/lf/preview | 91 |
5 files changed, 0 insertions, 513 deletions
diff --git a/dotfiles/system/.config/lf/cleaner b/dotfiles/system/.config/lf/cleaner deleted file mode 100755 index a184d84..0000000 --- a/dotfiles/system/.config/lf/cleaner +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -if [ -n "$FIFO_UEBERZUG" ]; then - printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG" -fi diff --git a/dotfiles/system/.config/lf/draw_img b/dotfiles/system/.config/lf/draw_img deleted file mode 100755 index 5a70d5e..0000000 --- a/dotfiles/system/.config/lf/draw_img +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -clear_screen() { - printf '\e[%sH\e[9999C\e[1J%b\e[1;%sr' \ - "$((LINES-2))" "${TMUX:+\e[2J}" "$max_items" -} - -# Get a file's mime_type. -mime_type=$(file -bi "$1") - -# File isn't an image file, give warning. -if [[ $mime_type != image/* ]]; then - lf -remote "send $id echoerr 'Not an image'" - exit -fi - -w3m_paths=(/usr/{local/,}{lib,libexec,lib64,libexec64}/w3m/w3mi*) -read -r w3m _ < <(type -p w3mimgdisplay "${w3m_paths[@]}") -read -r LINES COLUMNS < <(stty size) - -# Get terminal window size in pixels and set it to WIDTH and HEIGHT. -export $(xdotool getactivewindow getwindowgeometry --shell) - -# Get the image size in pixels. -read -r img_width img_height < <("$w3m" <<< "5;${CACHE:-$1}") - -((img_width > WIDTH)) && { - ((img_height=img_height*WIDTH/img_width)) - ((img_width=WIDTH)) -} - -((img_height > HEIGHT)) && { - ((img_width=img_width*HEIGHT/img_height)) - ((img_height=HEIGHT)) -} - -# Variable needed for centering image. -HALF_HEIGHT=$(expr $HEIGHT / 2) -HALF_WIDTH=$(expr $WIDTH / 2) -HALF_IMG_HEIGHT=$(expr $img_height / 2) -HALF_IMG_WIDTH=$(expr $img_width / 2) -X_POS=$(expr $HALF_WIDTH - $HALF_IMG_WIDTH) -Y_POS=$(expr $HALF_HEIGHT - $HALF_IMG_HEIGHT) - -clear_screen -# Hide the cursor. -printf '\e[?25l' - -# Display the image. -printf '0;1;%s;%s;%s;%s;;;;;%s\n3;\n4\n' \ - ${X_POS:-0} \ - ${Y_POS:-0} \ - "$img_width" \ - "$img_height" \ - "${CACHE:-$1}" | "$w3m" &>/dev/null - -# Wait for user input. -read -ern 1 - -# Clear the image. -printf '6;%s;%s;%s;%s\n3;' \ - "${X_POS:-0}" \ - "${Y_POS:-0}" \ - "$WIDTH" \ - "$HEIGHT" | "$w3m" &>/dev/null - -clear_screen diff --git a/dotfiles/system/.config/lf/image b/dotfiles/system/.config/lf/image deleted file mode 100755 index 77ddb5b..0000000 --- a/dotfiles/system/.config/lf/image +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -readonly ID_PREVIEW="preview" -main() { - case "$1" in - "clear") - declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \ - > "$FIFO_UEBERZUG" - ;; - "draw") - declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" \ - [x]="$3" [y]="$4" [max_width]="$5" [max_height]="$6" \ - [path]="$2") > "$FIFO_UEBERZUG" - ;; - "*") echo "Unknown command: '$1', '$2'" ;; - esac -} -main "$@" - diff --git a/dotfiles/system/.config/lf/lfrc b/dotfiles/system/.config/lf/lfrc deleted file mode 100644 index 50f5af9..0000000 --- a/dotfiles/system/.config/lf/lfrc +++ /dev/null @@ -1,333 +0,0 @@ -# lffc -# Craig Jennings <c@cjennings.net> -# - - -########################################################################## -# BASIC SETTINGS # -########################################################################## - -set ratios 1:2:3 -set cleaner ~/.config/lf/cleaner # path to cleaner script -set previewer ~/.config/lf/preview # path to preview script -set preview # turn on previews - -set nohidden # don't show hidden files. '.' toggles -set incsearch true # incremental searching -set drawbox # draw boxes around panes -set noicons # turn on icons -set ignorecase # ignore case in sorting & searching -set filesep " " # separate files w/ space not newline - -set shell sh -set shellopts '-eu' - -########################################################################## -# REMOVE SOME DEFAULT BINDINGS # -########################################################################## - -map m -map o -map n -map "'" -map '"' -map d -map c -map e -map f - -########################################################################## -# BASIC COMMANDS # -########################################################################## - -map . set hidden! # toggle hidden files -map p paste -map x cut -map y copy -map H top -map L bottom -map R reload -map C clear -map U unselect - -########################################################################## -# LF CONFIG EDIT/NAV -########################################################################## - -# LF CONFIG -#edit lfrc -map elf $$EDITOR ~/.config/lf/lfrc &! - -# goto lf dir -map glf cd ~/.config/lf/ - -# reload lfrc -map <f-5> push :source<space>~/.config/lf/lfrc<enter> - -########################################################################## -# CUSTOM COMMANDS # -########################################################################## - -# SET WALLPAPER BACKGROUND -map bg $feh --bg-fill "$f" - -# ROTATE IMAGE 90 degrees clockwise -map 90 mogrify -rotate 90 "$f" - -# DETOX FILENAME -map dtx $detox "$f" - -# COPY FILE PATH -map Y $echo "$fx" | clip - -# ADD TO DOTFILES REPO -map atd /usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME add "$f" - - -########################################################################## -# NAVIGATION / FILE MANAGEMENT # -########################################################################## - -### MAIN -map mh. $mv "$f" ~ -map ch. $cp "$f" ~ -map gh. cd ~ - -map mdx $mv "$f" ~/documents -map cdx $cp "$f" ~/documents -map gdx cd ~/documents - -map mdl $mv "$f" ~/downloads -map cdl $cp "$f" ~/downloads -map gdl cd ~/downloads - -### PICTURES -map mpx $mv "$f" ~/pictures -map cpx $cp "$f" ~/pictures -map gpx cd ~/pictures - -map mps $mv "$f" ~/pictures/screenshots -map cps $cp "$f" ~/pictures/screenshots -map gps cd ~/pictures/screenshots - -map mpw $mv "$f" ~/pictures/wallpaper -map cpw $cp "$f" ~/pictures/wallpaper -map gpw cd ~/pictures/wallpaper - -### MAME - -map mmr $mv "$f" ~/.mame/roms -map cmr $cp "$f" ~/.mame/roms -map gmr cd ~/.mame/roms -map owm /usr/bin/mame "$f" - -### MISC -map gtc cd ~/downloads/torrents/complete -map gulb cd /usr/local/bin -map gp0 cd ~/.vids -map mp0 $mv "$f" ~/.vids - -map gmv cd ~/movies -map mmv $mv "$f" ~/movies - -########################################################################## -# OPEN WITH COMMANDS # -########################################################################## - -# open with vlc video player (default: mpv) -map owv $vlc "$f" - -# open with gimp (default: nsxiv) -map owg $gimp "$f" - -# open with zathura (default emacs pdf-tools) -map owz $zathura "$f" - -# open with audacious -map owa $audacious "$f" - -########################################################################## -# FILE OPERATION # -########################################################################## - - -# RENAME -# -cmd rename %[ -e $1 ] && printf "file exists" || mv "$f" $1 -map r push :rename<space> - - -# OPEN -# -# Called when current file is not a directory. -cmd open ${{ - # if text or json file - case $(file --mime-type "$f" -bL) in - text/*|application/json) $EDITOR "$f";; - - *) xdg-open "$f" ;; - esac -}} -map <enter> open - - -# DELETE -# -cmd delete $rm -rf "$fx" -map dd delete - -map <delete> delete - -# MKDIR -# -cmd mkdir ${{ - printf "Directory Name: " - read ans - mkdir $ans -}} -map md mkdir - - -# MKFILE -# -cmd mkfile ${{ - printf "File Name: " - read ans - $EDITOR $ans -}} -map mf mkfile - - -# SUDO MKFILE -# -cmd sudomkfile ${{ - printf "File Name: " - read ans - sudo $EDITOR $ans -}} -map mr sudomkfile - - -# CHMOD -# -cmd chmod ${{ - printf "Mode Bits: " - read ans - for file in "$fx" - do - chmod $ans $file - done - lf -remote 'send reload' -}} -map ch chmod - - -######################################################################## # -# COMPRESSION FUNCTIONS # -######################################################################## # - -# EXTRACT -cmd extract ${{ - case "$f" in - *.tar.bz2) tar xjf "$f" ;; - *.tar.gz) tar xzf "$f" ;; - *.bz2) bunzip2 "$f" ;; - *.rar) rar x "$f" ;; - *.gz) gunzip "$f" ;; - *.tar) tar xf "$f" ;; - *.tbz2) tar xjf "$f" ;; - *.tgz) tar xzf "$f" ;; - *.zip) unzip "$f" ;; - *.Z) uncompress "$f" ;; - *) echo "Unsupported format" ;; - esac -}} -map ex extract - - -# TARGZ -# tar.gz current or selected files -# -cmd targz ${{ - set -f - mkdir $1 - cp -r "$fx" $1 - tar czf $1.tar.gz $1 - rm -rf $1 -}} -map tgz targz - - -# ZIP -# zip current file or selected files -cmd zip ${{ - set -f - mkdir $1 - cp -r "$fx" $1 - zip -r $1.zip $1 - rm -rf $1 -}} -map zip zip - - -######################################################################## # -# MISCELLANEOUS CONVENIENCE COMMANDS # -######################################################################## # - - -# PACMAN INSTALL -# -cmd pacman_install ${{ - case "$f" in - *.pkg.tar.xz|*.pkg.tar.gz|*.pkg.tar.zst) sudo pacman -U "$f" ;; - *) echo "This doesn't look like an Arch package, so not installing." -}} - - -# MP3 -# convert audio file to mp3 -# -cmd mp3 ${{ - set -f - outname=$(echo "$f" | cut -f 1 -d '.') - lame -V --preset extreme $f "${outname}.mp3" -}} - - -######################################################################## # -# FZF HELPER FUNCTIONS # -######################################################################## # - - -# FZF-JUMP -# -# jump to file or directory with c-f -cmd fzf_jump ${{ - res="$(find . -maxdepth 1 | fzf --reverse --header='Jump to location' | sed 's/\\/\\\\/g;s/"/\\"/g')" - if [ -d "$res" ] ; then - cmd="cd" - elif [ -f "$res" ] ; then - cmd="select" - else - exit 0 - fi - lf -remote "send $id $cmd \"$res\"" -}} -map <c-f> :fzf_jump - - -# FZF-SEARCH -# -# search contents of files in current directory, then select a file -cmd fzf_search ${{ - res="$( \ - RG_PREFIX="rg --column --line-number --no-heading --color=always \ - --smart-case " - FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \ - fzf --bind "change:reload:$RG_PREFIX {q} || true" \ - --ansi --layout=reverse --header 'Search in files' \ - | cut -d':' -f1 - )" - [ ! -z "$res" ] && lf -remote "send $id select \"$res\"" -}} -map gs :fzf_search diff --git a/dotfiles/system/.config/lf/preview b/dotfiles/system/.config/lf/preview deleted file mode 100755 index 68cda52..0000000 --- a/dotfiles/system/.config/lf/preview +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -image() { - geometry="$(($2-2))x$3" - chafa "$1" -f sixel -s "$geometry" --animate false -} - -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 -} - -glowormdcat() { - file="$1" - shift - if command -v glow > /dev/null 2>&1 - then - glow "$file" - else - mdcat "$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")" | awk '{print tolower($0)}')" 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" ;; - *.md) - glowormdcat "$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" ;; - *.xml|*.html) w3m -dump "$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" - ;; - *.epub) - [ ! -f "$CACHE" ] && \ - epub-thumbnailer "$1" "$CACHE" 1024 - image "$CACHE" "$2" "$3" "$4" "$5" - ;; - *.cbz|*.cbr|*.cbt) - [ ! -f "$CACHE" ] && \ - comicthumb "$1" "$CACHE" 1024 - image "$CACHE" "$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|*.tiff|*.gif|*.jfif|*.ico) - image "$1" "$2" "$3" "$4" "$5" - ;; - *.svg) - [ ! -f "${CACHE}.jpg" ] && \ - convert "$1" "${CACHE}.jpg" - image "${CACHE}.jpg" "$2" "$3" "$4" "$5" - ;; - *.ino) - batorcat --language=cpp "$1" - ;; - *) - batorcat "$1" - ;; -esac -exit 0 |
