thriller@localhost ~ :) cat .bin/d
#!/bin/sh
# inspired by http://l29ah-home.wtf.la/scripts/d
# this script can be used with a various POSIX compliant shells such a bash or dash.
. ~/.config/mime_launcher
tmpdir=/tmp
if ls $1 >/dev/null 2>/dev/null; then
fn=$1
else
fn=$tmpdir/$(cat /dev/urandom | head -n 1 | grep -ao '[A-Za-z0-9_]*' | tr -d '\n' | head -c 20)
wget $1 -O $fn || exit 1
fi
f=$(file --mime-type -b $fn)
echo MIME type of $fn is $f
for launcher in $(echo $f | sed -e 's/[/-]/_/g') $(echo $f | tr '/' ' ' | awk '{print $1}'); do
mexec_$launcher $fn && break
done
thriller@localhost ~ :) cat .config/mime_launcher
#!/bin/sh
mexec_image(){
gthumb $1
}
mexec_audio(){
mplayer $1
}
mexec_video(){
mplayer $1
}
mexec_application_octet_stream(){
# Плохо, да. А что поделать, жизнь такая
f=$(file -b $1)
echo $f
case "$f" in
"Microsoft ASF")
mplayer $1
;;
*)
echo 'nyoro~n'
exit 1
;;
esac
}
mexec_application_x_gzip(){
tar xvf $1 || gunzip $1
}
thriller@localhost ~ :) # Здесь были примеры использования, но они все примитивные, и я решил выкинуть их нафиг.