From ba7303e5b852ecd96e6acf35d8fb1427c9be9c62 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Tue, 5 Jul 2022 14:07:51 +0530 Subject: [PATCH] switching from ranger to lf --- .config/lf/cleaner | 4 + .config/lf/lfrc | 114 ++++++ .config/lf/scope | 44 ++ .config/ranger/plugins/__init__.py | 0 .../plugins/ranger_devicons/__init__.py | 15 - .../plugins/ranger_devicons/devicons.py | 381 ------------------ .config/ranger/rc.conf | 8 - .config/shell/aliasrc | 2 +- .config/shell/profile | 162 ++++++++ .local/bin/dmenuumount | 44 ++ .local/bin/lfub | 24 ++ .local/bin/rotdir | 12 + .local/share/applications/file.desktop | 2 +- 13 files changed, 406 insertions(+), 406 deletions(-) create mode 100755 .config/lf/cleaner create mode 100644 .config/lf/lfrc create mode 100755 .config/lf/scope delete mode 100644 .config/ranger/plugins/__init__.py delete mode 100644 .config/ranger/plugins/ranger_devicons/__init__.py delete mode 100644 .config/ranger/plugins/ranger_devicons/devicons.py delete mode 100644 .config/ranger/rc.conf create mode 100755 .local/bin/dmenuumount create mode 100755 .local/bin/lfub create mode 100755 .local/bin/rotdir diff --git a/.config/lf/cleaner b/.config/lf/cleaner new file mode 100755 index 0000000..a184d84 --- /dev/null +++ b/.config/lf/cleaner @@ -0,0 +1,4 @@ +#!/bin/sh +if [ -n "$FIFO_UEBERZUG" ]; then + printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG" +fi diff --git a/.config/lf/lfrc b/.config/lf/lfrc new file mode 100644 index 0000000..4d9a134 --- /dev/null +++ b/.config/lf/lfrc @@ -0,0 +1,114 @@ +# Basic vars +set shellopts '-eu' +set ifs "\n" +set scrolloff 10 +set icons +set period 1 +set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" +set cleaner '~/.config/lf/cleaner' +set previewer '~/.config/lf/scope' + +# cmds/functions +cmd open ${{ + case $(file --mime-type "$(readlink -f $f)" -b) in + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;; + image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;; + text/*|application/json|inode/x-empty) $EDITOR $fx;; + image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;; + image/svg+xml) display -- $f ;; + image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\|ico\)\(_large\)*$" | + setsid -f sxiv -aio 2>/dev/null | while read -r file; do + [ -z "$file" ] && continue + lf -remote "send select \"$file\"" + lf -remote "send toggle" + done & + ;; + audio/*) mpv --audio-display=no $f ;; + video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;; + application/pdf|application/vnd*|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;; + application/pgp-encrypted) $EDITOR $fx ;; + *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;; + esac +}} + +cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')" + +cmd extract ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + printf "%s\n\t" "$fx" + printf "extract?[y/N]" + read ans + [ $ans = "y" ] && aunpack $fx +}} + +cmd delete ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + printf "%s\n\t" "$fx" + printf "delete?[y/N]" + read ans + [ $ans = "y" ] && rm -rf -- $fx +}} + +cmd moveto ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + clear; echo "Move to where?" + dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && + for x in $fx; do + eval mv -iv \"$x\" \"$dest\" + done && + notify-send "🚚 File(s) moved." "File(s) moved to $dest." +}} + +cmd copyto ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + clear; echo "Copy to where?" + dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && + for x in $fx; do + eval cp -ivr \"$x\" \"$dest\" + done && + notify-send "πŸ“‹ File(s) copied." "File(s) copies to $dest." +}} + +cmd setbg "$1" +cmd bulkrename $vidir + +# Bindings +map $lf -remote "send $id select \"$(fzf)\"" +map J $lf -remote "send $id cd $(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)" +map gh +map g top +map D delete +map E extract +map C copyto +map M moveto +map push :mkdir +map reload +map set hidden! +map shell +map x $$f +map X !$f +map o &mimeopen $f +map O $mimeopen --ask $f + +map A rename # at the very end +map c push A # new rename +map I push A # at the very beginning +map i push A # before extension +map a push A # after extension +map B bulkrename +map b $setbg $f + +map down +map up +map V push :!nvim + +map W $setsid -f $TERMINAL >/dev/null 2>&1 + +map Y $printf "%s" "$fx" | xclip -selection clipboard + +# Source Bookmarks +#source "~/.config/lf/shortcutrc" diff --git a/.config/lf/scope b/.config/lf/scope new file mode 100755 index 0000000..50ab4d5 --- /dev/null +++ b/.config/lf/scope @@ -0,0 +1,44 @@ +#!/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 +} + +ifub() { + [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1 +} + +# 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. + +case "$(file --dereference --brief --mime-type -- "$1")" in + 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) cat "$1" ;; + application/zip) atool --list -- "$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" + ;; + *opendocument*) odt2txt "$1" ;; + application/pgp-encrypted) gpg -d -- "$1" ;; +esac +exit 1 diff --git a/.config/ranger/plugins/__init__.py b/.config/ranger/plugins/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/.config/ranger/plugins/ranger_devicons/__init__.py b/.config/ranger/plugins/ranger_devicons/__init__.py deleted file mode 100644 index 664b276..0000000 --- a/.config/ranger/plugins/ranger_devicons/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -import os -import ranger.api -from ranger.core.linemode import LinemodeBase -from .devicons import * - -SEPARATOR = os.getenv('RANGER_DEVICONS_SEPARATOR', ' ') - -@ranger.api.register_linemode -class DevIconsLinemode(LinemodeBase): - name = "devicons" - - uses_metadata = False - - def filetitle(self, file, metadata): - return devicon(file) + SEPARATOR + file.relative_path diff --git a/.config/ranger/plugins/ranger_devicons/devicons.py b/.config/ranger/plugins/ranger_devicons/devicons.py deleted file mode 100644 index ba67667..0000000 --- a/.config/ranger/plugins/ranger_devicons/devicons.py +++ /dev/null @@ -1,381 +0,0 @@ -#!/usr/bin/python -# coding=UTF-8 -# These glyphs, and the mapping of file extensions to glyphs -# has been copied from the vimscript code that is present in -# https://github.com/ryanoasis/vim-devicons -import re; -import os; - -# Get the XDG_USER_DIRS directory names from enviromental variables - -xdgs_dirs = {path.split('/')[-2]: icon for key, icon in [ - ('XDG_DOCUMENTS_DIR' , ''), - ('XDG_DOWNLOAD_DIR' , 'ο’˜'), - ('XDG_CONFIG_DIR' , 'ξœ‡'), - ('XDG_MUSIC_DIR' , 'ο€₯'), - ('XDG_PICTURES_DIR' , ''), - ('XDG_PUBLICSHARE_DIR', ''), - ('XDG_TEMPLATES_DIR' , 'οƒ…'), - ('XDG_VIDEOS_DIR' , ''), -] if (path := os.getenv(key))} - - -# all those glyphs will show as weird squares if you don't have the correct patched font -# My advice is to use NerdFonts which can be found here: -# https://github.com/ryanoasis/nerd-fonts -file_node_extensions = { - '7z' : '', - 'a' : '', - 'ai' : '', - 'apk' : '', - 'asm' : 'ξ˜”', - 'asp' : 'ξž•', - 'aup' : '', - 'avi' : 'ο€ˆ', - 'awk' : 'ξž•', - 'bash' : 'ξž•', - 'bat' : 'ξ˜•', - 'bmp' : '', - 'bz2' : '', - 'c' : '', - 'c++' : '', - 'cab' : '', - 'cbr' : '', - 'cbz' : '', - 'cc' : '', - 'class' : '', - 'clj' : '', - 'cljc' : '', - 'cljs' : 'ξͺ', - 'cmake' : '', - 'coffee' : 'ξ˜›', - 'conf' : 'ξ˜•', - 'cp' : '', - 'cpio' : '', - 'cpp' : '', - 'cs' : '', - 'csh' : 'ξž•', - 'css' : 'ξ˜”', - 'cue' : '', - 'cvs' : 'ξ˜•', - 'cxx' : '', - 'd' : '', - 'dart' : '', - 'db' : 'ξœ†', - 'deb' : '', - 'diff' : '', - 'dll' : '', - 'doc' : 'ο€­', - 'docx' : 'ο€­', - 'dump' : 'ξœ†', - 'edn' : 'ξͺ', - 'eex' : '', - 'efi' : 'ξž•', - 'ejs' : '', - 'elf' : 'ξž•', - 'elm' : '', - 'epub' : 'ο€­', - 'erl' : '', - 'ex' : '', - 'exe' : '', - 'exs' : '', - 'f#' : '', - 'fifo' : 'ο³£', - 'fish' : 'ξž•', - 'flac' : '', - 'flv' : 'ο€ˆ', - 'fs' : '', - 'fsi' : '', - 'fsscript' : '', - 'fsx' : '', - 'gem' : '', - 'gemspec' : 'ξž‘', - 'gif' : '', - 'go' : '', - 'gz' : '', - 'gzip' : '', - 'h' : '', - 'haml' : '', - 'hbs' : '', - 'hh' : '', - 'hpp' : '', - 'hrl' : '', - 'hs' : '', - 'htaccess' : 'ξ˜•', - 'htm' : '', - 'html' : '', - 'htpasswd' : 'ξ˜•', - 'hxx' : '', - 'ico' : '', - 'img' : 'ξœ†', - 'ini' : 'ξ˜•', - 'iso' : 'ξœ†', - 'jar' : '', - 'java' : '', - 'jl' : '', - 'jpeg' : '', - 'jpg' : '', - 'js' : '', - 'json' : 'ξ˜‹', - 'jsx' : '', - 'key' : '', - 'ksh' : 'ξž•', - 'leex' : '', - 'less' : 'ξ˜”', - 'lha' : '', - 'lhs' : '', - 'log' : 'ο‡ͺ', - 'lua' : '', - 'lzh' : '', - 'lzma' : '', - 'm4a' : '', - 'm4v' : 'ο€ˆ', - 'markdown' : 'ξ˜‰', - 'md' : 'ξ˜‰', - 'mdx' : 'ξ˜‰', - 'mjs' : '', - 'mkv' : 'ο€ˆ', - 'ml' : 'Ξ»', - 'mli' : 'Ξ»', - 'mov' : 'ο€ˆ', - 'mp3' : '', - 'mp4' : 'ο€ˆ', - 'mpeg' : 'ο€ˆ', - 'mpg' : 'ο€ˆ', - 'msi' : '', - 'mustache' : '', - 'nix' : 'οŒ“', - 'o' : '', - 'ogg' : '', - 'part' : 'ξŽ„', - 'pdf' : '', - 'php' : '', - 'pl' : '', - 'pm' : '', - 'png' : '', - 'pp' : 'ο’™', - 'ppt' : '', - 'pptx' : '', - 'ps1' : 'ξž•', - 'psb' : '', - 'psd' : '', - 'pub' : '', - 'py' : 'ξ˜†', - 'pyc' : 'ξ˜†', - 'pyd' : 'ξ˜†', - 'pyo' : 'ξ˜†', - 'r' : 'ο³’', - 'rake' : 'ξž‘', - 'rar' : '', - 'rb' : 'ξž‘', - 'rc' : 'ξ˜•', - 'rlib' : '', - 'rmd' : 'ξ˜‰', - 'rom' : 'ξž•', - 'rpm' : '', - 'rproj' : 'ο«…', - 'rs' : '', - 'rss' : 'ξ˜™', - 'rtf' : 'ο€­', - 's' : 'ξ˜”', - 'sass' : 'ξ˜ƒ', - 'scala' : '', - 'scss' : 'ξ˜ƒ', - 'sh' : 'ξž•', - 'slim' : '', - 'sln' : '', - 'so' : '', - 'sql' : 'ξœ†', - 'styl' : 'ξ˜€', - 'suo' : '', - 'swift' : '', - 't' : '', - 'tar' : '', - 'tex' : 'ο­¨', - 'tgz' : '', - 'toml' : 'ξ˜•', - 'torrent' : '', - 'ts' : '', - 'tsx' : '', - 'twig' : '', - 'vim' : 'ξŸ…', - 'vimrc' : 'ξŸ…', - 'vue' : 'ο΅‚', - 'wav' : '', - 'webm' : 'ο€ˆ', - 'webmanifest' : 'ξ˜‹', - 'webp' : '', - 'xbps' : '', - 'xcplayground' : '', - 'xhtml' : '', - 'xls' : '', - 'xlsx' : '', - 'xml' : '', - 'xul' : '', - 'xz' : '', - 'yaml' : 'ξ˜•', - 'yml' : 'ξ˜•', - 'zip' : '', - 'zsh' : 'ξž•', -} - -dir_node_exact_matches = { -# English - '.git' : 'ξ—»', - 'Desktop' : 'ο„ˆ', - 'Documents' : '', - 'Downloads' : 'ο’˜', - 'Dotfiles' : 'ξœ‡', - 'Dropbox' : 'ξœ‡', - 'Music' : 'ο€₯', - 'Pictures' : '', - 'Public' : '', - 'Templates' : 'οƒ…', - 'Videos' : '', -# Spanish - 'Escritorio' : 'ο„ˆ', - 'Documentos' : '', - 'Descargas' : 'ο’˜', - 'MΓΊsica' : 'ο€₯', - 'ImΓ‘genes' : '', - 'PΓΊblico' : '', - 'Plantillas' : 'οƒ…', - 'VΓ­deos' : '', -# French - 'Bureau' : 'ο„ˆ', - 'Documents' : '', - 'Images' : '', - 'Musique' : 'ο€₯', - 'Publique' : '', - 'TΓ©lΓ©chargements' : 'ο’˜', - 'VidΓ©os' : '', -# Portuguese - 'Documentos' : '', - 'Imagens' : '', - 'Modelos' : 'οƒ…', - 'MΓΊsica' : 'ο€₯', - 'PΓΊblico' : '', - 'VΓ­deos' : '', - 'Área de trabalho' : 'ο„ˆ', -# Italian - 'Documenti' : '', - 'Immagini' : '', - 'Modelli' : 'οƒ…', - 'Musica' : 'ο€₯', - 'Pubblici' : '', - 'Scaricati' : 'ο’˜', - 'Scrivania' : 'ο„ˆ', - 'Video' : '', -# German - 'Bilder' : '', - 'Dokumente' : '', - 'Musik' : 'ο€₯', - 'Schreibtisch' : 'ο„ˆ', - 'Vorlagen' : 'οƒ…', - 'Γ–ffentlich' : '', -# Hungarian - 'Dokumentumok' : '', - 'KΓ©pek' : '', - 'Modelli' : 'οƒ…', - 'Zene' : 'ο€₯', - 'LetΓΆltΓ©sek' : 'ο’˜', - 'SzΓ‘mΓ­tΓ³gΓ©p' : 'ο„ˆ', - 'VideΓ³k' : '', -# XDG_USER_DIRS - **xdgs_dirs -} - -file_node_exact_matches = { - '.bash_aliases' : 'ξ˜•', - '.bash_history' : 'ξ˜•', - '.bash_logout' : 'ξ˜•', - '.bash_profile' : 'ξ˜•', - '.bashprofile' : 'ξ˜•', - '.bashrc' : 'ξ˜•', - '.dmrc' : 'ξ˜•', - '.DS_Store' : 'ξ˜•', - '.fasd' : 'ξ˜•', - '.fehbg' : '', - '.gitattributes' : 'ξ˜•', - '.gitconfig' : 'ξ˜•', - '.gitignore' : 'ξ˜•', - '.gitlab-ci.yml' : 'οŠ–', - '.gvimrc' : '', - '.inputrc' : 'ξ˜•', - '.jack-settings' : 'ξ˜•', - '.mime.types' : 'ξ˜•', - '.ncmpcpp' : '', - '.nvidia-settings-rc' : 'ξ˜•', - '.pam_environment' : 'ξ˜•', - '.profile' : 'ξ˜•', - '.recently-used' : 'ξ˜•', - '.selected_editor' : 'ξ˜•', - '.vim' : 'ξŸ…', - '.viminfo' : 'ξŸ…', - '.vimrc' : 'ξŸ…', - '.Xauthority' : 'ξ˜•', - '.Xdefaults' : 'ξ˜•', - '.xinitrc' : 'ξ˜•', - '.xinputrc' : 'ξ˜•', - '.Xresources' : 'ξ˜•', - '.zshrc' : 'ξ˜•', - '_gvimrc' : '', - '_vimrc' : '', - 'a.out' : 'ξž•', - 'authorized_keys' : '', - 'bspwmrc' : 'ξ˜•', - 'cmakelists.txt' : 'ξ˜•', - 'config' : 'ξ˜•', - 'config.ac' : '', - 'config.m4' : '', - 'config.mk' : '', - 'config.ru' : 'ξž‘', - 'configure' : 'ξž•', - 'docker-compose.yml' : '', - 'dockerfile' : '', - 'Dockerfile' : '', - 'dropbox' : 'ξœ‡', - 'exact-match-case-sensitive-1.txt' : 'X1', - 'exact-match-case-sensitive-2' : 'X2', - 'favicon.ico' : '', - 'gemfile' : 'ξž‘', - 'gruntfile.coffee' : 'ξ˜‘', - 'gruntfile.js' : 'ξ˜‘', - 'gruntfile.ls' : 'ξ˜‘', - 'gulpfile.coffee' : '', - 'gulpfile.js' : '', - 'gulpfile.ls' : '', - 'ini' : 'ξ˜•', - 'known_hosts' : '', - 'ledger' : 'ο…•', - 'license' : '', - 'LICENSE' : '', - 'LICENSE.md' : '', - 'LICENSE.txt' : '', - 'Makefile' : 'ξ˜•', - 'makefile' : 'ξ˜•', - 'Makefile.ac' : 'ξ˜•', - 'Makefile.in' : 'ξ˜•', - 'mimeapps.list' : 'ξ˜•', - 'mix.lock' : '', - 'node_modules' : '', - 'package-lock.json' : '', - 'package.json' : '', - 'playlists' : '', - 'procfile' : 'ξ˜‡', - 'Rakefile' : 'ξž‘', - 'rakefile' : 'ξž‘', - 'react.jsx' : 'ξ˜₯', - 'README' : 'ξ˜‰', - 'README.markdown' : 'ξ˜‰', - 'README.md' : 'ξ˜‰', - 'README.rst' : 'ξ˜‰', - 'README.txt' : 'ξ˜‰', - 'sxhkdrc' : 'ξ˜•', - 'user-dirs.dirs' : 'ξ˜•', - 'webpack.config.js' : '', -} - -def devicon(file): - if file.is_directory: return dir_node_exact_matches.get(file.relative_path, 'ξ—Ώ') - return file_node_exact_matches.get(os.path.basename(file.relative_path), file_node_extensions.get(file.extension, 'ξ˜’')) diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf deleted file mode 100644 index d65afff..0000000 --- a/.config/ranger/rc.conf +++ /dev/null @@ -1,8 +0,0 @@ -# How many columns are there, and what are their relative widths? -set column_ratios 1,3,5 - -set show_hidden true -set draw_borders both -set preview_images true -set preview_images_method ueberzug -default_linemode devicons diff --git a/.config/shell/aliasrc b/.config/shell/aliasrc index ad6afdb..30f6182 100644 --- a/.config/shell/aliasrc +++ b/.config/shell/aliasrc @@ -12,7 +12,7 @@ alias \ ytdlm='yt-dlp -f "(mp3)"' \ cl='clear' \ dots='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' \ - fm='ranger' \ + lf="lfub" \ hst='history 1 -1 | cut -c 8- | sort | uniq | fzf | tr -d '\n' | xclip -sel c' # Verbosity and settings that you pretty much just always are going to want. diff --git a/.config/shell/profile b/.config/shell/profile index c6fcf0c..f0172c9 100644 --- a/.config/shell/profile +++ b/.config/shell/profile @@ -36,6 +36,168 @@ export MPD_PORT="6600" # Mpd daemon start [ ! -s ~/.config/mpd/pid ] && mpd +export LF_ICONS="\ +di=:\ +fi=:\ +ln=:\ +or=:\ +ex=:\ +*.vimrc=:\ +*.viminfo=:\ +*.gitignore=:\ +*.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=οŒ“:\ +" + # Starting X if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then exec startx diff --git a/.local/bin/dmenuumount b/.local/bin/dmenuumount new file mode 100755 index 0000000..946d12c --- /dev/null +++ b/.local/bin/dmenuumount @@ -0,0 +1,44 @@ +#!/bin/sh + +# A dmenu prompt to unmount drives. +# Provides you with mounted partitions, select one to unmount. +# Drives mounted at /, /boot and /home will not be options to unmount. + +unmountusb() { + [ -z "$drives" ] && exit + chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1 + chosen="$(echo "$chosen" | awk '{print $1}')" + [ -z "$chosen" ] && exit + sudo -A umount "$chosen" && notify-send "πŸ’» USB unmounting" "$chosen unmounted." + } + +unmountandroid() { \ + chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1 + [ -z "$chosen" ] && exit + sudo -A umount -l "$chosen" && notify-send "πŸ€– Android unmounting" "$chosen unmounted." + } + +asktype() { \ + choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1 + case "$choice" in + USB) unmountusb ;; + Android) unmountandroid ;; + esac + } + +drives=$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,":")}$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s) %s\n",$4,$3,$5}') + +if ! grep simple-mtpfs /etc/mtab; then + [ -z "$drives" ] && echo "No drives to unmount." && exit + echo "Unmountable USB drive detected." + unmountusb +else + if [ -z "$drives" ] + then + echo "Unmountable Android device detected." + unmountandroid + else + echo "Unmountable USB drive(s) and Android device(s) detected." + asktype + fi +fi diff --git a/.local/bin/lfub b/.local/bin/lfub new file mode 100755 index 0000000..9012f50 --- /dev/null +++ b/.local/bin/lfub @@ -0,0 +1,24 @@ +#!/bin/sh + +# This is a wrapper script for lb 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 + +cleanup() { + exec 3>&- + rm "$FIFO_UEBERZUG" +} + +if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + lf "$@" +else + [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf" + export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$" + mkfifo "$FIFO_UEBERZUG" + ueberzug layer -s <"$FIFO_UEBERZUG" -p json & + exec 3>"$FIFO_UEBERZUG" + trap cleanup HUP INT QUIT TERM PWR EXIT + lf "$@" 3>&- +fi diff --git a/.local/bin/rotdir b/.local/bin/rotdir new file mode 100755 index 0000000..86da6db --- /dev/null +++ b/.local/bin/rotdir @@ -0,0 +1,12 @@ +#!/bin/sh + +# When I open an image from the file manager in sxiv (the image viewer), I want +# to be able to press the next/previous keys to key through the rest of the +# images in the same directory. This script "rotates" the content of a +# directory based on the first chosen file, so that if I open the 15th image, +# if I press next, it will go to the 16th etc. Autistic, I know, but this is +# one of the reasons that sxiv is great for being able to read standard input. + +[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1 +base="$(basename "$1")" +ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }' diff --git a/.local/share/applications/file.desktop b/.local/share/applications/file.desktop index a8e458b..5df1633 100644 --- a/.local/share/applications/file.desktop +++ b/.local/share/applications/file.desktop @@ -1,4 +1,4 @@ [Desktop Entry] Type=Application Name=File Manager -Exec=/usr/local/bin/st -e fm %u +Exec=/usr/local/bin/st -e lfub %u