-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnxv
More file actions
executable file
·62 lines (56 loc) · 1.01 KB
/
nxv
File metadata and controls
executable file
·62 lines (56 loc) · 1.01 KB
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
59
60
61
62
#!/bin/bash
# Networked XV - jzu 2006 - WTFPL
# If you need xv, you need this.
if [ $# -eq 0 ]
then
echo Usage: `basename $0` '[-xv_options...]' url 1>&2
exit 1
fi
NARG=$#
OPTS="-nolimits "
for i in `seq 1 $(($NARG-1))`
do
OPTS="$OPTS $1"
shift
done
URL=$1
FILE=/tmp/$$-`basename $URL`
FILE=`echo $FILE \
| sed "s/\?.*//"`
rm -f $FILE
echo $URL \
| grep "://" > /dev/null 2>&1
if [ $? -eq 0 ]
then
wget --no-check-certificate -O $FILE $URL > /dev/null 2>&1
else
cp $URL $FILE
fi
WGETSTATUS=$?
file $FILE \
| grep "PNG image" &> /dev/null
PNGSTATUS=$?
if [ $PNGSTATUS -eq 0 ]
then
convert $FILE /tmp/nxvtmpfile-$$.gif
/bin/mv -f /tmp/nxvtmpfile-$$.gif $FILE
xv $OPTS $FILE
/bin/rm $FILE
else
if [ $WGETSTATUS -eq 0 ]
then
xv $OPTS $FILE
JPEGSTATUS=$?
if [ $JPEGSTATUS -eq 255 ]
then
convert $FILE /tmp/nxvtmpfile-$$
/bin/mv -f /tmp/nxvtmpfile-$$ $FILE
xv $OPTS $FILE
fi
rm -f $FILE
else
echo $URL not found 1>&2
rm -f $FILE
exit 2
fi
fi