Text only
26 Oct 2009
 
 
Tools: wrap/unwrap  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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 ~ :) # Здесь были примеры использования, но они все примитивные, и я решил выкинуть их нафиг.