1
0
Fork 0

use xdg-mime for file opening, add archivemount to lf

This commit is contained in:
Luca Bilke 2022-08-08 20:12:33 +02:00
parent e0fe1ce6ee
commit 6169a40426
2 changed files with 38 additions and 27 deletions
.config

View file

@ -2,6 +2,7 @@
set ratios 1:2:4
set shellopts '-eu'
set ifs "\n"
set findlen 2
set scrolloff 10
set icons
set wrapscroll
@ -11,35 +12,41 @@ set cleaner ~/.config/lf/clean
set promptfmt "\033[34;1m%u\033[36m@\033[34m%h \033[35m[\033[0;1m%d\033[33m%f\033[35m]\033[0m"
cmd open ${{
case $(xdg-mime query filetype "$1") in
*/x-bzip-compressed-tar|*/x-compressed-tar|*/x-7z-compressed|*/vnd.rar|*/x-tar|*/zip|*/x-java-archive|*/x-xz|*/x-cd-image)
mntdir="$f-archivemount"
[ ! -d "$mntdir" ] && {
case "$(xdg-mime query filetype "$f")" in
*/x-bzip-compressed-tar|*/x-compressed-tar|*/x-7z-compressed|*/vnd.rar|*/x-tar|*/zip|*/x-java-archive|*/x-xz|*/x-xz-compressed-tar|*/x-cd-image)
mntdir="$f-archivemount"
[ ! -d "$mntdir" ] && {
mkdir "$mntdir"
archivemount "$f" "$mntdir"
echo "$mntdir" >> "/tmp/__lf_archivemount_$id"
}
lf -remote "send $id cd \"$mntdir\""
lf -remote "send $id reload"
;;
}
lf -remote "send $id cd \"$mntdir\""
lf -remote "send $id reload"
;;
audio/*) mpv --audio-display=no $f ;;
video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
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 &
;;
*/vnd.djvu|*/pdf|*/postscript|*/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text) setsid -f lowriter $fx >/dev/null 2>&1 ;;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text) setsid -f lowriter $fx >/dev/null 2>&1 ;;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template) setsid -f localc $fx >/dev/null 2>&1 ;;
application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint) setsid -f loimpress $fx >/dev/null 2>&1 ;;
application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template) setsid -f lodraw $fx >/dev/null 2>&1 ;;
application/vnd.oasis.opendocument.formula) setsid -f lomath $fx >/dev/null 2>&1 ;;
application/vnd.oasis.opendocument.database) setsid -f lobase $fx >/dev/null 2>&1 ;;
esac
case $(file -bL --mime-type) in
*/vnd.openxmlformats-officedocument*) localc $fx ;;
*/pdf|application/vnd*|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
case $(file --mime-type "$(readlink -f $f)" -b) in
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/pgp-encrypted) $EDITOR $fx ;;
*) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
application/pgp-encrypted) $EDITOR $fx ;;
# *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
esac
}}

View file

@ -68,10 +68,14 @@ lfcd () {
fi
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
command rm -f "$tmp"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
rm -f "$tmp"
if [ -d "$dir" ]; then
if [ "$dir" != "$(pwd)" ]; then
cd "$dir"
fi
fi
fi
tput cuu1;tput el
# tput cuu1;tput el
}
_lfcd () {