#!/bin/bash ############################################### ## Welcome to the cdisplay homepage / script ## ############################################### # # cdisplay is a shell script which imitates the Windows software CDisplay. # # cdisplay will extract PKZIP, Roshal (RAR), or tape (TAR) archives and display # the image files within. This is great for reading comic books that have been # compressed into a one-file archive. It also detects CBZ and CBR archives, which # are the same as ZIP and RAR, respectively. # # It was written by by Andrew McMillan < andrew -within- mcmillan -d- net -d- nz > # who released it into the public domain. I edited it a little to support more # file extensions. (I take no credit.) # # cdisplay requires the ImageMagick viewer by default. You can change this yourself. # # To use cdisplay, save this file as "cdisplay" and make it executable. To install # cdisplay, simply move the file to a directory in your PATH. # # Here's where cdisplay's temporary directory goes. TMPDIR="/tmp/cdisplay-$$" # careful! it will get removed rm -rf "${TMPDIR}" >/dev/null 2>&1 trap "rm -rf \"${TMPDIR}\"; echo 'cleaned temporary directory'" EXIT ERR DIR="`dirname \"$1\"`" [ "$DIR" = "." ] && DIR="`pwd`" CBNAME="${DIR}/`basename \"$1\"`" case "${CBNAME}" in *cbr) ARC="unrar x" ;; *rar) ARC="unrar x" ;; *cbz) ARC=unzip ;; *zip) ARC=unzip ;; *tar.gz) ARC="tar zxf" ;; *targz) ARC="tar zxf" ;; *tar.bz2) ARC="tar jxf" ;; *tarbz2) ARC="tar jxf" ;; *tar) ARC="tar xf" ;; *7z) ARC="7z x" ;; *) echo "Unknown file extension" exit 1 ;; esac echo "Looks like we should ${ARC} ${CBNAME}" mkdir "${TMPDIR}" cd "${TMPDIR}" ${ARC} "${CBNAME}" # Call ImageMagick (you can change it) find . -type f | sort | sed -e "s/^\(.*\)$/\"\1\"/" | xargs gqview