[bglug] Comix Viewer

k|b|s kbs@bglug.it
Ven 17 Lug 2009 16:58:23 CEST


Piacciono i manga?
Non so voi, ma con comix non mi trovo.
Quindi ecco cbview:

--8<-- CUT HERE --8<--
#!/bin/bash
# cbview
# Using qiv to view comic books or compressed image archives
# Time-stamp: <cbview,  17/7/2009 16:51:10 joe Exp>
# Joe Galaxy fecit MMIX

TNAME="`echo "$1" |tr ' ' '_' | tr -d '[{}(),\!#^]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g'`"
NAME=`basename ${TNAME%.[^.]*}`

TMP="/tmp/cbview/"$NAME""
if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi

gz="gunzip"
bz="bunzip2"
zip="unzip -qo"
rar="unrar x -id -y"
tar="tar xf"
z7="7z e"

if [ $# -eq 0 ]; then
    echo "Usage: cbview file">&2
    exit 1
fi

for name
do
	if [ ! -f "$name" ] ; then
		echo "$0: file $name not found." >&2
		continue
	fi

	if [ "$(echo $name | egrep '(\.gz$|\.bz2$|\.zip$|\.rar$|\.tar$|\.tgz$|\.7z$|\.cbz$|\.cbr$)')" = "" ] ; then
		echo "$0: file $name is not a valid archive" 
      		continue
	fi

	extension=${name##*.}

	case "$extension" in
		gz ) $gz "$name" $TMP
		      ;;
		bz2 ) $bz "$name" $TMP
		      ;;
		zip|cbz ) $zip -j -d $TMP "$name"
		      ;;
		rar|cbr ) $rar "$name" $TMP
		      ;;
		tar|tgz ) $tar "$name" -C "$TMP"
                      ;;
                7z ) $z7 -o $TMP "$name"
			  ;;
	esac

done

qiv -fum $TMP
#rm -rf $TMP
rm -rf /tmp/cbview

exit 0
--8<-- CUT HERE --8<--

Have fun ;)

-- 
★ ميكائيل ★



Maggiori informazioni sulla lista bglug