Krolyxon
Commit e70f5a5

Branches

Refs →

aurorae70f5a5

lf: open images in remage, drop rotdir

remage-pick hands remage's marks back as lf's selection. Trash on D
(restore with U), open-with menu, wl-copy yanks, more previews.
Author
krolyxon
Date
2026-11-05 16:20 +0530
Parent
db36078
Commit
e70f5a5d010fd8f5e60e46a5dbb93afd057280cf

+158 −78

9 files changed

  1. M .config/lf/lfrc +85 −42
  2. M .config/lf/mvdirs +11 −11
  3. A .config/lf/remage-pick +14 −0
  4. M .config/lf/scope +46 −11
  5. M .config/shell/aliasrc +0 −1
  6. D .local/bin/rotdir +0 −12
  7. M packages/aur.txt +1 −0
  8. M packages/desktop.txt +0 −1
  9. M packages/utils.txt +1 −0
M .config/lf/lfrc View
@@ -1,94 +1,131 @@
11 # Basic vars
2−# set sixel true
32 set shellopts '-eu'
43 set ifs "\n"
54 set scrolloff 10
65 set icons
76 set hidden true
87 set drawbox true
9−set period 1
8+set roundbox true
9+set watch true # files other programs add or remove (remage, downloads, waldl) show up without polling
1010 set previewer '~/.config/lf/scope'
11+set preload true
1112 set autoquit true
1213
1314 # cmds/functions
1415 cmd open ${{
15− case $(file --mime-type "$(readlink -f $f)" -b) in
16− application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
16+ set -f
17+ case $(file --mime-type "$(readlink -f "$f")" -b) in
1718 image/vnd.djvu|application/pdf|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
1819 text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
19− image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
20− image/svg+xml) display -- $f ;;
21− image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\|heic\)\(_large\)*$" |
22− setsid -f remage -io 2>/dev/null | while read -r file; do
23− [ -z "$file" ] && continue
24− lf -remote "send select \"$file\""
25− lf -remote "send toggle"
26− done &
27− ;;
28− audio/*|video/x-ms-asf) mpv --audio-display=no $f ;;
29− video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
30− application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
20+ image/x-xcf) setsid -f gimp "$f" >/dev/null 2>&1 ;;
21+ # one image = remage on its whole directory, starting there; a selection = just those.
22+ # Images marked in remage (m) become the selection here.
23+ image/*) setsid -f ~/.config/lf/remage-pick $fx >/dev/null 2>&1 ;;
24+ audio/*|video/x-ms-asf) mpv --audio-display=no $fx ;;
25+ video/*) setsid -f mpv $fx -quiet >/dev/null 2>&1 ;;
26+ application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
3127 application/pgp-encrypted) $EDITOR $fx ;;
3228 application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f libreoffice $fx >/dev/null 2>&1 ;;
3329 application/octet-stream) case ${f##*.} in
3430 doc|docx|xls|xlsx|odt|ppt|pptx) setsid -f libreoffice $fx >/dev/null 2>&1 ;;
35− ghw) setsid -f gtkwave $f >/dev/null 2>&1 ;;
36− ts) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
31+ ghw) setsid -f gtkwave "$f" >/dev/null 2>&1 ;;
32+ ts) setsid -f mpv $fx -quiet >/dev/null 2>&1 ;;
3733 *) setsid -f zathura $fx >/dev/null 2>&1 ;;
3834 esac ;;
39− *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
35+ *) for f in $fx; do setsid -f xdg-open "$f" >/dev/null 2>&1; done;;
4036 esac
4137 }}
42−cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')"
38+
39+# pick any app registered for the file's type (gio mime) in aurora's runner
40+cmd open-with ${{
41+ set -f
42+ app=$(gio mime "$(file -Lb --mime-type -- "$f")" | sed -n 's/^\t\(.*\)\.desktop$/\1/p' | sort -u |
43+ aurora-run -d -p "open with:") || exit 0
44+ setsid -f gtk-launch "$app" $fx >/dev/null 2>&1
45+}}
46+
47+cmd mkdir %mkdir -p -- "$*"
48+cmd touch %touch -- "$*"
4349
4450 cmd extract ${{
4551 clear; tput cup $(($(tput lines)/3)); tput bold
4652 set -f
4753 printf "%s\n\t" "$fx"
4854 printf "extract?[y/N]"
49− read ans
50− [ $ans = "y" ] && ext $fx
55+ read -r ans
56+ [ "$ans" = "y" ] && ext $fx
57+}}
58+
59+# D: to the trash (gio, restorable with U); <delete>: gone for good
60+cmd trash %{{
61+ set -f
62+ gio trash -- $fx
63+ lf -remote "send $id :unselect; echo trashed $(printf '%s\n' "$fx" | wc -l) item(s), U restores"
64+}}
65+
66+cmd restore ${{
67+ pick=$(gio trash --list | awk -F '\t' '{ print $2 "\t" $1 }' |
68+ fzf --multi --delimiter '\t' --with-nth 1 --prompt "restore: ") || exit 0
69+ printf '%s\n' "$pick" | cut -f2 | while read -r uri; do gio trash --restore "$uri"; done
5170 }}
5271
5372 cmd delete ${{
5473 clear; tput cup $(($(tput lines)/3)); tput bold
5574 set -f
5675 printf "%s\n\t" "$fx"
57− printf "delete?[y/N]"
58− read ans
59− [ $ans = "y" ] && rm -rf -- $fx
76+ printf "delete permanently?[y/N]"
77+ read -r ans
78+ [ "$ans" = "y" ] && rm -rf -- $fx
6079 }}
6180
62−cmd moveto ${{
63− clear; tput cup $(($(tput lines)/3)); tput bold
81+# M / C: move / copy the selection to a directory from ~/.config/lf/mvdirs
82+cmd transfer ${{
6483 set -f
65− clear; echo "Move to where?"
66− dest=$(cat ~/.config/lf/mvdirs | fzf )
67− for x in $fx; do
68− eval mv -iv \"$x\" \"$dest\"
69− done &&
70− notify-send "🚚 File(s) moved." "File(s) moved to $dest."
84+ dest=$(sed "s|^\\\$HOME|$HOME|; s|^~|$HOME|" ~/.config/lf/mvdirs | fzf --prompt "$1 to: ") || exit 0
85+ if [ "$1" = move ]; then mv -iv -- $fx "$dest"; else cp -ivr -- $fx "$dest"; fi
86+ notify-send "lf" "$1: $(printf '%s\n' "$fx" | wc -l) item(s) to $dest"
87+}}
88+
89+cmd fzf-jump ${{
90+ res=$(fd --hidden --exclude .git | fzf --prompt "jump: ") || exit 0
91+ lf -remote "send $id select \"$(printf '%s' "$res" | sed 's/[\\"]/\\&/g')\""
7192 }}
7293
73−cmd setwall -p "$1"
94+# copy paths / names / the image itself
95+cmd yank-path %printf '%s' "$fx" | wl-copy && lf -remote "send $id echo copied path"
96+cmd yank-name %basename -a -- $fx | head -c -1 | wl-copy && lf -remote "send $id echo copied name"
97+cmd yank-dir %printf '%s' "$PWD" | wl-copy && lf -remote "send $id echo copied $PWD"
98+cmd yank-file %wl-copy --type "$(file -Lb --mime-type -- "$f")" < "$f" && lf -remote "send $id echo copied file contents"
99+
100+cmd setwall %setwall -p "$f"
101+
102+# window title = the directory (Hyprland, aurora's overview)
103+cmd on-cd &{{
104+ lf -remote "send $id tty-write \"\033]2;lf $(pwd | sed "s|^$HOME|~|")\007\""
105+}}
106+on-cd
74107
75108 # Bindings
76−map <c-f> $lf -remote "send $id select \"$(fzf)\""
77−map D delete
109+map <c-f> fzf-jump
110+map D trash
111+map <delete> delete
112+map U restore
78113 map p paste
79114 map dd cut
80−map M moveto
115+map M transfer move
116+map C transfer copy
81117 map yy copy
82118 map H top
83119 map E extract
84120 map <c-n> push :mkdir<space>
121+map <c-t> push :touch<space>
85122 map <c-r> reload
86123 map <c-s> set hidden!
87124 map <enter> shell
88125 map x $$f
89126 map X !$f
90−map o &mimeopen $f
91−map O $mimeopen --ask $f
127+map o &xdg-open "$f"
128+map O open-with
92129
93130 map A :rename; cmd-end # at the very end
94131 map c push A<c-u> # new rename
@@ -96,7 +133,7 @@ map I :rename; cmd-home # at the very beginning
96133 map i :rename # before extension
97134 map a :rename; cmd-right # after extension
98135 map br $vimv
99−map bg $setwall -p $f
136+map bg setwall
100137
101138 map <c-e> down
102139 map <c-y> up
@@ -104,14 +141,19 @@ map V push :!nvim<space>
104141
105142 map W $setsid -f $TERMINAL >/dev/null 2>&1
106143
107−map Y $printf "%s" "$fx" | xclip -selection clipboard
108−map T $nsxiv -t "$(pwd)" # opens thumbnail mode
144+map Y yank-path
145+map yp yank-path
146+map yn yank-name
147+map yd yank-dir
148+map yi yank-file
149+map T &~/.config/lf/remage-pick -t . # thumbnail grid of this directory, marks -> selection
109150 map <c-l> unselect
110151
111152 # movement
112153 map gd cd ~/dox/
113154 map gD cd ~/dl/
114155 map gp cd ~/pix
156+map gw cd ~/pix/wallpapers
115157 map gc cd ~/.config
116158 map gC cd ~/.cache
117159 map gr cd ~/code/repos
@@ -121,4 +163,5 @@ map gM cd ~/media
121163 map gn cd ~/music
122164 map gb cd ~/.local/bin
123165 map gt cd /tmp
166+map gT cd ~/.local/share/Trash/files
124167 map gs cd ~/.local/share
M .config/lf/mvdirs View
@@ -1,17 +1,17 @@
1−$HOME/.cache
2−$HOME/.config
31 $HOME
4−$HOME/.local/bin
5−$HOME/.local/src
6−$HOME/.local/share
72 $HOME/dl
83 $HOME/dox
9−$HOME/music
10−$HOME/movies
11−$HOME/vids
124 $HOME/pix
135 $HOME/pix/ss
14−$HOME/pix/wallpapers/
15−$HOME/dev/
16−$HOME/dev/
6+$HOME/pix/wallpapers
7+$HOME/pix/wallhaven
8+$HOME/vids
9+$HOME/music
10+$HOME/media
11+$HOME/code
12+$HOME/dev
13+$HOME/.config
14+$HOME/.cache
15+$HOME/.local/bin
16+$HOME/.local/share
1717 /tmp
A .config/lf/remage-pick View
@@ -0,0 +1,14 @@
1+#!/bin/sh
2+# Run from lf (needs $id): remage ARGS..., then the images marked there (m) become lf's selection.
3+# One file = remage opens its whole directory at that file; several = just those; -t DIR = the grid.
4+
5+marked=$(remage -o "$@" 2>/dev/null)
6+[ -n "$marked" ] || exit 0
7+
8+files=""
9+while IFS= read -r file; do
10+ files="$files \"$(printf '%s' "$file" | sed 's/[\\"]/\\&/g')\""
11+done <<EOF
12+$marked
13+EOF
14+lf -remote "send $id :unselect; toggle$files"
M .config/lf/scope View
@@ -1,14 +1,49 @@
11 #!/bin/sh
2+# lf previewer: $1 file, $2 width, $3 height (cells). Exit 0 = lf may cache the output (set preload).
3+
4+cache="${XDG_CACHE_HOME:-$HOME/.cache}/lf"
5+# thumbnail path for $1: changes when the file does
6+thumb() {
7+ mkdir -p "$cache"
8+ printf '%s/thumb.%s' "$cache" "$(stat -L --printf '%n\0%i\0%s\0%Y' -- "$1" | sha256sum | cut -d' ' -f1)"
9+}
10+image() {
11+ chafa -f sixel -s "${2}x${3}" --animate off --polite on -t 1 --bg black -- "$1"
12+}
13+
214 case "$(file -Lb --mime-type -- "$1")" in
3− image/*)
4− chafa -f sixel -s "$2x$3" --animate off --polite on -t 1 --bg black "$1"
5− ;;
6− video/*)
7− 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)"
8− ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0
9− chafa -f sixel -s "$2x$3" --animate off --polite on -t 1 --bg black "$CACHE"
10− ;;
11− text/*)
12− bat "$1"
13− ;;
15+ image/svg+xml)
16+ t=$(thumb "$1").png
17+ [ -s "$t" ] || magick -background none -density 192 "$1" -resize 1024x1024 "$t"
18+ image "$t" "$2" "$3"
19+ ;;
20+ image/*)
21+ image "$1" "$2" "$3"
22+ ;;
23+ video/*)
24+ t=$(thumb "$1").jpg
25+ [ -s "$t" ] || ffmpegthumbnailer -i "$1" -o "$t" -s 1024 -q 6 >/dev/null 2>&1
26+ image "$t" "$2" "$3"
27+ ;;
28+ application/pdf)
29+ t=$(thumb "$1")
30+ [ -s "$t.jpg" ] || pdftoppm -jpeg -f 1 -l 1 -singlefile -scale-to 1024 -- "$1" "$t"
31+ image "$t.jpg" "$2" "$3"
32+ ;;
33+ audio/*)
34+ ffprobe -v error -show_entries format=duration,bit_rate:format_tags -of default=nw=1 -- "$1" |
35+ sed 's/^TAG://'
36+ ;;
37+ application/zip|application/x-tar|application/gzip|application/x-7z-compressed|application/vnd.rar|\
38+ application/x-rar|application/x-xz|application/x-bzip2|application/zstd|application/x-zstd|\
39+ application/java-archive|application/x-iso9660-image|application/x-cpio|application/vnd.debian.binary-package)
40+ bsdtar -tf "$1"
41+ ;;
42+ text/*|application/json|application/*xml|application/javascript|application/x-subrip|application/x-ndjson|\
43+ application/toml|application/x-wine-extension-ini|application/pgp-keys|inode/x-empty)
44+ bat --color=always --style=numbers --paging=never --terminal-width "$2" -- "$1"
45+ ;;
46+ *)
47+ file -Lb -- "$1"
48+ ;;
1449 esac
M .config/shell/aliasrc View
@@ -9,7 +9,6 @@ alias \
99 ls='eza -x' \
1010 lsa='eza -la' \
1111 nb="newsboat" \
12− sxiv="nsxiv" \
1312 hst="history 1 -1 | cut -c 8- | sort | uniq | fzf | tr -d '\n' | wl-copy" \
1413
1514 # Verbosity and settings that you pretty much just always are going to want.
D .local/bin/rotdir View
@@ -1,12 +0,0 @@
1−#!/bin/sh
2−
3−# When I open an image from the file manager in sxiv (the image viewer), I want
4−# to be able to press the next/previous keys to key through the rest of the
5−# images in the same directory. This script "rotates" the content of a
6−# directory based on the first chosen file, so that if I open the 15th image,
7−# if I press next, it will go to the 16th etc. Autistic, I know, but this is
8−# one of the reasons that sxiv is great for being able to read standard input.
9−
10−[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
11−base="$(basename "$1")"
12−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; }'
M packages/aur.txt View
@@ -4,3 +4,4 @@ htop-vim
44 jmtpfs
55 zsh-fast-syntax-highlighting-git
66 claude-code
7+remage-bin
M packages/desktop.txt View
@@ -41,7 +41,6 @@ wireplumber
4141
4242 # Apps the configs/keybinds assume
4343 foot
44−nsxiv
4544 xdg-utils
4645 curl
4746 udisks2
M packages/utils.txt View
@@ -69,6 +69,7 @@ ffmpegthumbnailer
6969 imagemagick
7070 imlib2
7171 chafa
72+poppler
7273 perl-image-exiftool
7374 tesseract
7475 zathura