diff options
| author | Akshay Nair <phenax5@gmail.com> | 2020-12-21 14:17:42 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2020-12-21 14:17:42 +0530 |
| commit | ebab2f2586739a9e7d0df38f9a1b2eca18b7c719 (patch) | |
| tree | ca630f596ba2ce011021e5516f237f3527e5db96 /config/lf | |
| parent | 810a3e60ca64e18a11b55ec7e1c2d85e56e51bd5 (diff) | |
| download | nixos-config-ebab2f2586739a9e7d0df38f9a1b2eca18b7c719.tar.gz nixos-config-ebab2f2586739a9e7d0df38f9a1b2eca18b7c719.zip | |
Moves ls and dunst configs and enables notifications
Diffstat (limited to 'config/lf')
| -rw-r--r-- | config/lf/lfrc | 117 | ||||
| -rwxr-xr-x | config/lf/lfrun.sh | 18 | ||||
| -rwxr-xr-x | config/lf/previewer.sh | 50 |
3 files changed, 185 insertions, 0 deletions
diff --git a/config/lf/lfrc b/config/lf/lfrc new file mode 100644 index 0000000..2114fd7 --- /dev/null +++ b/config/lf/lfrc @@ -0,0 +1,117 @@ +set hidden true +# set color256 true +set drawbox true +set icons true +set ignorecase true +set relativenumber true +set ratios 2:3 + +set preview false +set previewer ~/.config/lf/previewer.sh + +# Function definitions {{{ +cmd open_inplace ${{ + case $(file --mime-type "$f" -bL) in + text/*|application/json) $EDITOR "$fx" 2&> /dev/null ;; + video/*) setsid -f swallow mpv "$f" 2&> /dev/null ;; + image/gif) setsid -f swallow mpv "$f" 2&> /dev/null ;; + image/*) setsid -f swallow sxiv "$f" 2&> /dev/null ;; + application/pdf) setsid -f swallow zathura "$f" 2&> /dev/null ;; + *) + for f in "$fx"; do + open "$f" + done + ;; + esac; + disown; +}} + +cmd open ${{ + case $(file --mime-type "$f" -bL) in + text/*|application/json) $EDITOR "$fx" ;; + video/*|application/pdf) open "$f" & ;; + *) + for f in "$fx"; do + open "$f" + done + ;; + esac; + disown; +}} + +cmd mkdir ${{ + printf "Directory Name: " + read ans + mkdir $ans +}} + +cmd mkfile ${{ + printf "File Name: " + read ans + $EDITOR $ans +}} + +cmd move_to_trash ${{ + mkdir -p /tmp/.trash-cache/ + echo "$fx" | while read file; do + mv "$file" /tmp/.trash-cache/ + done; +}} + +cmd rename %{{ + printf " Rename to: " + read ans + mv "$f" "$ans" +}} + +cmd set_wallpaper $feh --bg-scale "$f" + +cmd show_images ${{ + if [ "$(echo "$fx" | wc -l)" = "1" ]; then + swallow sxiv $(dirname "$fx") & + else + swallow sxiv $fx & + fi; +}} + +# }}} + +# Unset old keys {{{ + map w + map m + map n + map "'" + map '"' + map d}} + map c + map e + map d +# }}} + +# Mutations +map dd move_to_trash +map p paste +map x cut +map y copy +map mf mkfile +map md mkdir +map wp set_wallpaper +map rr rename + + +# View changes +map <enter> open_inplace +map si show_images +map du $du -h -d1 | less +map sh :set hidden! +map st :set sortby time + + +# Traversal keys +map gde cd ~/Desktop +map gdl cd ~/Downloads/dl +map gdm cd ~/Downloads/music +map gdv cd ~/dev +map gs cd ~/scripts +map gp cd ~/Pictures + diff --git a/config/lf/lfrun.sh b/config/lf/lfrun.sh new file mode 100755 index 0000000..e350c3f --- /dev/null +++ b/config/lf/lfrun.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +export FIFO_UEBERZUG="/tmp/lf-ueberzug-${PPID}"; +export LAST_IMAGE_F="/tmp/lf-ueberzug-${PPID}-last-img"; + +function cleanup { + ~/scripts/image.sh clear; + rm "$FIFO_UEBERZUG" 2>/dev/null + pkill -P $$ +} + +mkfifo "$FIFO_UEBERZUG" 2&>/dev/null; +mkfifo "$LAST_IMAGE_F" 2&>/dev/null; + +trap cleanup EXIT +tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash & + +lf "$@"; diff --git a/config/lf/previewer.sh b/config/lf/previewer.sh new file mode 100755 index 0000000..1b748e1 --- /dev/null +++ b/config/lf/previewer.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +width=`echo "$(tput cols) / 2" | bc`; +height=`echo "$(tput lines) - 3" | bc`; + +x=$((width - 3)); +y=3; + +~/scripts/image.sh clear; + +case "$1" in + # Archives + *.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";; + *.o) nm "$1" | less ;; + *.apk) mediainfo "$1" ;; + + # Docs + *.md|*.org) glow -s dark "$1" ;; + *.csv) cat "$1" | sed s/,/\\n/g ;; + *.pdf) pdftotext "$1" - ;; + *.docx) docx2txt "$1" - ;; + *.epub) mediainfo "$1" ;; + *.[1-8]) man "$1" | col -b ;; + + # Images + *.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp) mediainfo "$1"; ;; + + #*.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp) + #~/scripts/image.sh draw "$1" "$x" "$y" "$width" "$height"; + #;; + + # Audio + *.wav|*.mp3|*.flac|*.m4a|*.wma|*.ape|*.ac3|*.og[agx]|*.spx|*.opus|*.as[fx]|*.flac) + mediainfo "$1" + ;; + + # Video + *.avi|*.mp4|*.wmv|*.dat|*.3gp|*.ogv|*.mkv|*.mpg|*.mpeg|*.vob|*.fl[icv]|*.m2v|*.mov|*.webm|*.ts|*.mts|*.m4v|*.r[am]|*.qt|*.divx) + mediainfo "$1"; + ;; + + # Syntax + *) highlight --out-format ansi "$1" || cat "$1" ;; +esac |
