make some things better
This commit is contained in:
parent
2409682a56
commit
27e7153b71
|
@ -1,17 +1,25 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Determining MIME type of $1:"
|
||||
argv0="$0"
|
||||
|
||||
MIME=$(curl -I -s "$1" | sed -n -e 's/^[cC]ontent-[tT]ype: //p' | sed -e 's/;.\+//g' | tr -d '\r')
|
||||
if ! test -n "$1"; then
|
||||
printf "Usage: %s [resource...]\n" "$argv0"
|
||||
exit 64 # sysexits(3) EX_USAGE
|
||||
fi
|
||||
|
||||
echo $MIME
|
||||
test -n "$BROWSER" || BROWSER=$(cat /etc/xdg-sanity.conf | sed -n -e 's/^browser = //p' )
|
||||
|
||||
BROWSER=$(cat /etc/xdg-sanity.conf | sed -n -e 's/^browser = //p' )
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
printf "%s: Missing dependency: curl(1)\n" "$argv0"
|
||||
exit 71 # sysexits(3) EX_OSERR
|
||||
fi
|
||||
|
||||
if [ "$MIME" = "text/html" ]
|
||||
then
|
||||
$BROWSER $1
|
||||
MIME="$(curl -s -o /dev/null -w '%{content_type}' $1 | sed 's/\;.*//' | xargs echo)"
|
||||
|
||||
# determine the MIME type, strip everything after the first semicolon, and
|
||||
# check to see if it's HTML
|
||||
if [ "$MIME"= "text/html" ]; then
|
||||
$BROWSER $1
|
||||
else
|
||||
handlr launch "$MIME" -- "$1"
|
||||
fi
|
||||
handlr launch "$MIME" -- "$1"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue