Update 2024-10-20 18:21 OpenBSD/amd64-t14

This commit is contained in:
c0dev0id 2024-10-20 18:21:51 +02:00
parent 634ce7bc79
commit de5b108398
2 changed files with 54 additions and 67 deletions

View File

@ -1,6 +1,6 @@
#!/bin/ksh
f=$1
f="$1"
if [ -z "$f" ];
then
@ -9,9 +9,10 @@ then
fi
###################################################
# URLS
# SSH
###################################################
# SSH
if print "$f" | egrep -qi '^shell:|^ushell:|^cvs:|^home:';
then
_server=${f%%:*}
@ -20,84 +21,70 @@ then
exit 0
fi
###################################################
# TRY TO FIND MIME TYPE
###################################################
if print "$f" | egrep -qi '^http[s]{0,1}://';
then
case "$f" in
*.mkv) mpv "$f"; ;;
*.mp4) mpv "$f"; ;;
*.webm) mpv "$f"; ;;
*) sacc "$f"; ;;
esac
${BROWSER:=vimb} "$f"
exit 0
MIME="$(webmime "$f")"
TYPE="http"
fi
if print "$f" | egrep -qi '^gopher://';
if print "$f" | egrep -qi '^gopher[s]{0,1}://';
then
case "$f" in
*.mkv) mpv "$f"; ;;
*.mp4) mpv "$f"; ;;
*.webm) mpv "$f"; ;;
*) sacc "$f"; ;;
esac
exit 0
MIME=""
TYPE="gopher"
fi
###################################################
# REAL FILES
###################################################
if [ ! -f "$f" ];
if [ -f "$f" ]
then
print "Parameter is not a file."
exit 1
MIME="$(file -ib "$f")"
TYPE="file"
fi
###################################################
# EXTENSIONS
# TRANSLATE MIME TYPES TO EXTENSIONS
###################################################
case "$MIME" in
# full qualified
application/ogg) EXT=ogg; ;;
application/pdf) EXT=pdf; ;;
application/postscript) EXT=ps; ;;
application/vnd.oasis.opendocument.*) EXT=docx; ;;
audio/mpeg) EXT=mpg; ;;
audio/midi) EXT=midi; ;;
image/webp) EXT=webp; ;;
application/x-gzip) EXT=gz; ;;
# with wildcards
audio/*) EXT=generic_audio; ;;
video/*) EXT=generic_video; ;;
image/*) EXT=generic_image; ;;
# vim can handle a lot!
text/*) EXT=generic_text; ;;
esac
EXT="$(print "${f##*.}" | tr '[:upper:]' '[:lower:]')"
# no extension yet? Extract from file
[ -z "$EXT" ] && EXT="$(print "${f##*.}" | tr '[:upper:]' '[:lower:]')"
case "$EXT" in
docx) libreoffice "$f"; ;;
xlsx) libreoffice "$f"; ;;
txt) vim "$f"; ;;
m2ts) mpv "$f"; ;;
flv) mpv "$f"; ;;
mp3) aplay "$f"; ;;
aiff) mpva "$f"; ;;
sid) sidplay "$f"; ;;
out) kdump -RTf "$f" | less; ;;
torrent) aria2c "$f"; ;;
*) unset EXT; ;;
esac
if [ ! -z "$EXT" ];
then
exit 0;
fi
###################################################
# MIME TYPES
###################################################
case "$(file -ib "$f")" in
# full qualified
application/ogg) aplay "$f"; ;;
application/pdf) zathura "$f"; ;;
application/postscript) zathura "$f"; ;;
application/vnd.oasis.opendocument.*) libreoffice "$f"; ;;
audio/mpeg) aplay "$f"; ;;
audio/midi) timidity "$f"; ;;
# with wildcards
audio/*) aplay "$f"; ;;
video/*) mpv "$f"; ;;
image/webp) mpv "$f"; ;;
image/*) nsxiv -N floating -g 1280x720+300+180 -ab "$f"; ;;
# can't handle
application/octet-stream) print "Sorry, can't handle: $f"; ;;
# vim can handle a lot!
*) vim "$f"; ;;
aiff) EXEC="mpv"; ;;
mkv) EXEC="mpv"; ;;
docx) EXEC="libreoffice"; ;;
flv) EXEC="mpv"; ;;
m2ts) EXEC="mpv"; ;;
mp3) EXEC_TERM="aplay"; ;;
mp4) EXEC="mpv"; ;;
out) EXEC="kdump -RTf"; ;;
sid) EXEC="sidplay"; ;;
torrent) EXEC="aria2c"; ;;
txt) EXEC="vim"; ;;
webm) EXEC="mpv"; ;;
xlsx) EXEC="libreoffice"; ;;
generic_text) EXEC="vim"; ;;
generic_video) EXEC="mpv"; ;;
generic_audio) EXEC="mpv"; ;;
esac
echo "TYPE=$TYPE | MIME=$MIME | EXT=.$EXT | EXEC=$EXEC"
[ ! -z "$EXEC" ] && exec $EXEC "$f"
exit 0

View File

@ -23,4 +23,4 @@ then
exit 1
fi
echo "$R"
echo "$R" | col -b