Added more openers/previewers
This commit is contained in:
parent
e6155942cc
commit
525abf5357
2 changed files with 39 additions and 25 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
# Basic vars
|
# Basic vars
|
||||||
set shellopts '-eu'
|
set shellopts '-eu'
|
||||||
set ifs "\n"
|
set ifs "\n"
|
||||||
|
|
@ -12,24 +14,36 @@ set autoquit true
|
||||||
# cmds/functions
|
# cmds/functions
|
||||||
cmd open ${{
|
cmd open ${{
|
||||||
case $(file --mime-type "$(readlink -f $f)" -b) in
|
case $(file --mime-type "$(readlink -f $f)" -b) in
|
||||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
|
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
|
||||||
image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
|
localc $fx ;;
|
||||||
text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
|
image/vnd.djvu|application/pdf|application/octet-stream|application/postscript)
|
||||||
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
|
setsid -f zathura $fx >/dev/null 2>&1 ;;
|
||||||
image/svg+xml) display -- $f ;;
|
text/*|application/json|inode/x-empty|application/x-subrip)
|
||||||
image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
|
$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\|avif\|tif\|ico\)\(_large\)*$" |
|
||||||
setsid -f sxiv -aio 2>/dev/null | while read -r file; do
|
setsid -f sxiv -aio 2>/dev/null | while read -r file; do
|
||||||
[ -z "$file" ] && continue
|
[ -z "$file" ] && continue
|
||||||
lf -remote "send select \"$file\""
|
lf -remote "send select \"$file\""
|
||||||
lf -remote "send toggle"
|
lf -remote "send toggle"
|
||||||
done &
|
done &
|
||||||
;;
|
;;
|
||||||
audio/*|video/x-ms-asf) mpv --audio-display=no $f ;;
|
audio/*|video/x-ms-asf)
|
||||||
video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
|
mpv --audio-display=no $f ;;
|
||||||
application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
|
video/*)
|
||||||
application/pgp-encrypted) $EDITOR $fx ;;
|
setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
|
||||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|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 ;;
|
application/pdf|application/vnd.djvu|application/epub*)
|
||||||
*) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
|
setsid -f zathura $fx >/dev/null 2>&1 ;;
|
||||||
|
application/pgp-encrypted)
|
||||||
|
$EDITOR $fx ;;
|
||||||
|
application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|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 ;;
|
||||||
|
*)
|
||||||
|
for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
|
||||||
esac
|
esac
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,25 +31,25 @@ case "$(file --dereference --brief --mime-type -- "$1")" in
|
||||||
text/* | */xml | application/json)
|
text/* | */xml | application/json)
|
||||||
bat --terminal-width "$(($4-2))" -f "$1"
|
bat --terminal-width "$(($4-2))" -f "$1"
|
||||||
;;
|
;;
|
||||||
# audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;;
|
audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;;
|
||||||
# video/* )
|
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)"
|
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
|
[ ! -f "$CACHE" ] && ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0
|
||||||
# image "$CACHE" "$2" "$3" "$4" "$5" "$1"
|
image "$CACHE" "$2" "$3" "$4" "$5" "$1"
|
||||||
# ;;
|
;;
|
||||||
# */pdf)
|
*/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)"
|
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"
|
[ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
|
||||||
# image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
|
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
|
||||||
# ;;
|
;;
|
||||||
# */epub+zip|*/mobi*)
|
# */epub+zip|*/mobi*)
|
||||||
# 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)"
|
# 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" ] && gnome-epub-thumbnailer "$1" "$CACHE.jpg"
|
# [ ! -f "$CACHE.jpg" ] && gnome-epub-thumbnailer "$1" "$CACHE.jpg"
|
||||||
# image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
|
# image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
|
||||||
# ;;
|
# ;;
|
||||||
# application/*zip) atool --list -- "$1" ;;
|
application/*zip) atool --list -- "$1" ;;
|
||||||
# *opendocument*) odt2txt "$1" ;;
|
# *opendocument*) odt2txt "$1" ;;
|
||||||
# application/pgp-encrypted) gpg -d -- "$1" ;;
|
application/pgp-encrypted) gpg -d -- "$1" ;;
|
||||||
*)
|
*)
|
||||||
file -ibL "$1" | grep -q text && batorcat "$1" || file -Lb "$1"
|
file -ibL "$1" | grep -q text && batorcat "$1" || file -Lb "$1"
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue