complete refactor
This commit is contained in:
parent
8c9b55bb96
commit
9a1c33d0d1
@ -1,44 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Loading extensions..."
|
||||
|
||||
INPUT=$(echo $1)
|
||||
echo "Loading configuration..."
|
||||
CONFIG=$(cat /etc/xdg-sanity/xdg-sanity.conf)
|
||||
BROWSER=$(echo $CONFIG | sed -ne 's/^browser *= *//p')
|
||||
|
||||
if [ "$BROWSER" = "" ]
|
||||
then
|
||||
echo "Please place the path to your default browser's executable in /etc/xdg-sanity/xdg-sanity.conf"
|
||||
exit
|
||||
else
|
||||
echo "Found default browser $BROWSER"
|
||||
fi
|
||||
|
||||
echo "Loading extensions..."
|
||||
for EXT in /etc/xdg-sanity/extensions/*.sh
|
||||
do
|
||||
|
||||
if [ "$EXT" = "/etc/xdg-sanity/extensions/*.sh" ]
|
||||
then
|
||||
echo "No extensions to load"
|
||||
else
|
||||
|
||||
for EXT in /etc/xdg-sanity/extensions/*.sh
|
||||
do
|
||||
TYPE=$(cat $EXT | sed -ne 's/^# EXT-TYPE=//p' | tr -d '\n')
|
||||
echo "Found $TYPE extension $EXT"
|
||||
|
||||
if [ "$TYPE" = "replace" ]
|
||||
then
|
||||
INPUT=$($EXT "$INPUT")
|
||||
echo "Modifying $INPUT..."
|
||||
INPUT=$($EXT "$INPUT")
|
||||
echo "Got $INPUT"
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$TYPE" = "mime" ]
|
||||
then
|
||||
echo "Modifying MIME type..."
|
||||
MIME=$($EXT "$INPUT")
|
||||
echo $MIME
|
||||
echo "Got $MIME"
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
echo "Determining MIME type of $INPUT:"
|
||||
|
||||
if [ "$MIME" = "$1" ]
|
||||
if [ "$MIME" = "" ] || [ "$MIME" = "$1" ] || [ "$MIME" = "$INPUT" ]
|
||||
then
|
||||
echo "Determining MIME type of $INPUT:"
|
||||
MIME=$(curl -I -s "$INPUT" | sed -ne 's/^[cC]ontent-[tT]ype: //p' | sed -e 's/;.\+//g' | tr -d '\r')
|
||||
fi
|
||||
|
||||
echo $MIME
|
||||
|
||||
BROWSER=$(cat /etc/xdg-sanity/xdg-sanity.conf | sed -ne 's/^browser = //p' )
|
||||
fi
|
||||
|
||||
if [ "$MIME" = "text/html" ]
|
||||
then
|
||||
$BROWSER $INPUT
|
||||
|
||||
else
|
||||
handlr launch "$MIME" -- "$INPUT"
|
||||
fi
|
@ -2,9 +2,9 @@
|
||||
|
||||
# EXT-TYPE=mime
|
||||
|
||||
TEST=$(echo $1 | sed -ne 's/^h.\+\/\///p' | sed -ne 's/\/.*\+//p')
|
||||
TEST=$(echo $1 | sed -ne 's/^h.\+\/\///p' | sed -e 's/\/.*\+//g')
|
||||
|
||||
if [ $TEST = "teddit.net" ]
|
||||
if [ "$TEST" = "teddit.net" ]
|
||||
then
|
||||
echo "text/html"
|
||||
else
|
||||
|
@ -2,10 +2,9 @@
|
||||
|
||||
# EXT-TYPE=replace
|
||||
|
||||
TEST=$(echo $1 | sed -ne 's/^h.\+\/\///p' | sed -ne 's/\/.*\+//p')
|
||||
TEST=$(echo $1 | sed -ne 's/^h.\+\/\///p' | sed -e 's/\/.*\+//g')
|
||||
|
||||
|
||||
if [ $TEST = "youtube.com" ]
|
||||
if [ "$TEST" = "youtube.com" ]
|
||||
then
|
||||
echo $1 | sed -ne 's/youtube.com/piped.mint.lgbt/p'
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user