Package: zgv Version: 5.9-2+b1 Severity: wishlist Below is an adaptation of the fimgs script, zgs, to use zgv in compliment of fim/fbi to view pdf, ps etc., allowing use of unique zgv features such as generation/viewing/selection via thumbnails. The script is not perfect right now, could use a bit of cleanup, but is usable. Thanks for any feedback/consideration. --
#!/bin/bash VERSION="$Id: zgs,v 1.1 2010/11/16 07:20:00 dallas Exp dallas $" ; # (c) 2010 Dallas Legan # This is a modified version of the original fimgs script,by Michele Matone # and is capable of displaying pdf, eps, ps, and dvi files. # Now enhanced for viewing .cbr and .cbz files :)! # # Note : it won't probably work on bash, version < 3.0 because of regular expressions. # this script wants a temporary directory to stores rendered/wget'ed files # this directory is named after the process ID # ####################################################################### # ######## Start: Functions, Variables, etc. ################################# # ####################################################################### USAGE="${0##*/} [ -h | -v ] [ -T ] [ -s ] [ -p PDF-PASSWORD] [ -c PRE-COMMANDS ] [ -F FINAL-COMMANDS ] FILES" DIR="${TMPDIR-/var/tmp}/fbps-$$" # we must have write permissions in that directory mkdir -p $DIR || exit 1 # we want that directory clean after this script execution, no matter what happens trap "rm -rf $DIR" EXIT # as advised in man which, for mysterious reasons ( C compatible ) which () { ( alias; declare -f ; ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@ } #export -f which # checks if the first supplied argument is in the current $PATH function check_in_path() { local cmd="$1"; [[ -z "$cmd" ]] && return 0 [[ -z $(which "$cmd" 2>/dev/null) ]] && return -1 return 0 } function help_message () { cat <<EOHELP ${USAGE} -T - Pass tagged files to FINAL_COMMANDS -s - Pass dimensions of last displayed file to FINAL_COMMANDS Note that FILE can be a (correctly named) :" PDF (.pdf) file" Postscript (.ps) file" TAR (.tar) archive" BZ2 (.bz2) archive" GZIP (.gz) archive" https:// resource (web resource)" http:// resource (web resource)" Note that you cannot view files names like the options (no -- meta-option)." `man zgs` will give you more info." EOHELP } # output functions function info() { echo ' [+]' "$@" 1>&2 ; } function einfo() { echo ' [-]' "$@" 1>&2 ; } function die() { einfo "ERROR : "$@ 1>&2 ; exit -1 ; } # ####################################################################### # ######## End: Functions, Variables, etc. ################################# # ####################################################################### # our favourite framebuffer viewing program :) # FBI=fim ZGV=zgv check_in_path $ZGV || die "no zgv in \$PATH" # check_in_path sort || die "no sort in \$PATH" check_in_path echo || die "no echo in \$PATH" # check_in_path find || die "no find in \$PATH" check_in_path wget || die "no wget in \$PATH" check_in_path gs || die "no gs (ghostscript) in \$PATH" check_in_path tar || die "no tar in \$PATH" check_in_path basename || die "no basename in \$PATH" check_in_path md5sum || die "no md5sum in \$PATH" #check_in_path rar || die "no rar in \$PATH" #check_in_path unzip || die "no unzip in \$PATH" #check_in_path scp || die "no scp in \$PATH" # parse options # fbiopts="-w" zgvopts="-j --reload-delay 1000000 " # -j apparently needed for framebuffer svgalib driver gsopts="-q" passwd="" opt=1 # in this way odd filenames are kept intact, be WARNED while test "$opt" = "1" #set -- `getopt "" "$@"` #while [ ! -z "$1" ] do case "$1" in # -l) gsopts="$gsopts -r100x100" # shift # ;; # -xl) gsopts="$gsopts -r120x120" # shift # ;; # -xxl) gsopts="$gsopts -r150x150" # shift # ;; # -q | -a) # fbiopts="$fbiopts $1" # shift # ;; # -d | -m | -t | -g | -f) # fbiopts="$fbiopts $1 $2" # shift; shift # ;; # explicit option passing # -t) fbiopts="$fbiopts --no-framebuffer" # shift # ;; -s | --show-dimensions ) zgvopts="${zgvopts} --show-dimensions " ; shift ; ;; -T | --show-tagged ) zgvopts="${zgvopts} --show-tagged " ; shift ; ;; -c) zgvpre="$2" shift 2 ; ;; -F) zgvpost="$2" shift 2 ; ;; -p) password="$2" shift 2 ; ;; [-/][hH?]* | --[hH]* ) #help text help_message ; exit 1 ; ;; [-/][vV]* | --[vV]* ) echo ${VERSION} ; exit 1 ; ;; *) [[ "$1" =~ '^-.*' ]] && zgvopts="$zgvopts $1"; break;; # -*) echo "unknown option: $1" # exit 1 # ;; # *) opt=0 # ;; esac # shift done cat <<ZGVSUMMARY zgv image viewer command summary: (Generally vi / lynx - vi mode cursor controls) Alt-u - generate/update thumbnail images (Suggested for tiled overview of document) ? - help / - help for video modes available v - toggle file selector mode between graphical or text ESC - return to previous mode (eventually exiting) Enter - go to the next image : - display file information ; - reset brightness/contract/etc. to default Ctrl-I - start a slide show of files tagged in file selector mode. Ctrl-R - refresh view/directory Ctrl-L - refresh view/directory Right Mouse button - context sensitive menu Left Mouse button - select an image or directory in file selector/directory view mode ZGVSUMMARY ############################################################################### ## HANDLING OF CBR AND CBZ ARCHIVES ############################################################################### UNCBZ="unzip" ; ZOPT="-x '*/*'" # suits for Info-ZIP implementation UNCBR="rar x" # suits for Alexander Roshal's RAR 3.51 UNTAR="tar xf" UNTGZ="tar xzf" UNBZ="tar xjf" #while [[ "$1" != "" ]] #while [[ "$#" -gt "0" ]] while test "$opt" = "1" #while shift do f="$1"; shift 1 ; [[ "$f" =~ 'https://' ]] && { fn="$DIR"/"`basename $f`" && wget "$f" -O "$fn" && trap "rm $fn" EXIT ; f="$fn"; } [[ "$f" =~ 'http://' ]] && { fn="$DIR"/"`basename $f`" && wget "$f" -O "$fn" && trap "rm $fn" EXIT ; f="$fn"; } [[ "$f" =~ 'ssh:' ]] && { bfn="`basename ${f/#ssh:/}`" && fn="$DIR"/"`echo $bfn | sed s/^.*://`" && scp "${f/ssh:/}" "$fn" && trap "rm $fn" EXIT ; f="$fn"; } [[ -z "$f" ]] && break ; #while [[ ! -f "$f" ]] ; do shift ; [[ "$#" -lt 0 ]] && break 2 ; done ############################################################################### ## HANDLING OF DVI,PS AND PDF FILES ############################################################################### #[[ "$f" =~ .dvi$ ]] && f="/tmp/$$.ps" && dvips -q "$f" -o "$f" && trap "rm $f ; rm -fRd $DIR" EXIT #[[ -f "$f" ]] || { echo "an option!" ; fbiopts="$fbiopts $f" ; break ; } # not a file, but an option #d.e.l. [[ "$f" =~ .dvi$ ]] && fbiopts=" -P $fbiopts" #d.e.l. [[ "$f" =~ .pdf$ ]] && fbiopts=" -P $fbiopts" #d.e.l. [[ "$f" =~ .ps$ ]] && fbiopts=" -P $fbiopts" #d.e.l. [[ "$f" =~ .eps$ ]] && fbiopts=" -P $fbiopts" if ( [[ "$f" =~ .ps$ ]] || [[ "$f" =~ .pdf$ ]] ) || ( [[ "$f" =~ .eps$ ]] || [[ "$f" =~ .dvi$ ]] ) then BDIR='' if check_in_path md5sum then DIRS=$(echo "$f" | md5sum ) DIRS=${DIRS// /} DIRS=${DIRS//-/} BDIR="$DIR/$DIRS" # this means that giving duplicate input files will overwrite the original render directory... else BDIR="$DIR/"$(basename "$f") fi mkdir -p $BDIR || die "failed mkdir $BDIR" info "rendering $f to $BDIR.." #this is a workaround for gs's .. bug .. [[ "$f" =~ "^\.\." ]] && f="$PWD/$f" # note : we cannot render gs renderable documents with more than 1000 pages... gs -dSAFER -dNOPAUSE -dBATCH \ -sPDFPassword="$password" \ -sDEVICE=png256 -r240x240 -sOutputFile=$BDIR/ps%03d.png \ $gsopts \ "$f" || die "ghostscript failed rendering!" # still unused options : # -sDEVICE=tiffpack \ # -sOutputFile=$DIR/ps%03d.tiff # tell the user we are done :-) #echo -ne "\\007" #echo stuff : `ls -l $DIR` #echo "contents of $DIR:" #$FBI $fbiopts -P $DIR/ps*.png #$FBI $fbiopts -P $DIR/ps*.png 2>/dev/null #fbi $fbiopts -P $DIR/ps*.tiff # sanity check #pages=`ls $DIR/ 2>/dev/null | wc -l` #if test "$pages" -eq "0"; then # echo # echo "Oops: ghostscript wrote no pages ($pages)?" # echo # exit 1 #elif ( ( [[ "$f" =~ \\.cbr$ ]] || [[ "$f" =~ \\.cbz$ ]] ) || ( [[ "$f" =~ \\.rar$ ]] || [[ "$f" =~ \\.zip$ ]] ) || ( [[ "$f" =~ \\.tgz$ ]] || [[ "$f" =~ \\.tar.gz$ ]] ) || ( [[ "$f" =~ \\.tar$ ]] || [[ "$f" =~ \\.tar.bz2$ ]] ) ) && ! [[ "$f" =~ '^http://' ]] elif ( ( [[ "$f" =~ .CBR$ ]] || [[ "$f" =~ .CBZ$ ]] || [[ "$f" =~ .cbr$ ]] || [[ "$f" =~ .cbz$ ]] ) || ( [[ "$f" =~ .rar$ ]] || [[ "$f" =~ .zip$ ]] ) || ( [[ "$f" =~ .tgz$ ]] || [[ "$f" =~ .tar.gz$ ]] ) || ( [[ "$f" =~ .tar$ ]] || [[ "$f" =~ .tar.bz2$ ]] ) ) && ! [[ "$f" =~ 'http://' ]] && ! [[ "$f" =~ 'https://' ]] then # in the case of an archive ... # an ideal fimgs script would unpack recursively in search for interesting files.. # 20070925 there were problems with '\\.' so i put '.' only :/ [[ "$f" =~ .cbr$ ]] && ( $UNCBR "$f" "$DIR" ) [[ "$f" =~ .CBR$ ]] && ( $UNCBR "$f" "$DIR" ) [[ "$f" =~ .rar$ ]] && ( $UNCBR "$f" "$DIR" ) [[ "$f" =~ .cbz$ ]] && ( $UNCBZ "$f" $ZOPT -d "$DIR" ) [[ "$f" =~ .CBZ$ ]] && ( $UNCBZ "$f" $ZOPT -d "$DIR" ) [[ "$f" =~ .zip$ ]] && ( $UNCBZ "$f" $ZOPT -d "$DIR" ) [[ "$f" =~ .tgz$ ]] && ( $UNTGZ "$f" -C "$DIR" ) [[ "$f" =~ .tar.gz$ ]] && ( $UNTGZ "$f" -C "$DIR" ) [[ "$f" =~ .tar$ ]] && ( $UNTAR "$f" -C "$DIR" ) [[ "$f" =~ .tar.bz2$ ]] && ( $UNBZ "$f" -C "$DIR" ) # ... but this fimgs script is lazy and it gets satisfied with a bare decompress ! # lone file handling.. #[[ "$?" == 0 ]] || echo "this script is not suited for file $f" else [[ -f "$DIR/`basename $f`" ]] || cp -- "$f" "$DIR" || die "problems copying $f to $DIR" fi #fi done # show pages #fbiopts= #$FBI $fbiopts -P -- $DIR/* $DIR/*/* $DIR/*/*/* $DIR/*/*/*/* $DIR/*/*/*/*/* $DIR/*/*/*/*/*/* $DIR/*/*/*/*/*/*/* #echo "options are $fbiopts" # there should be some filter to avoid feed garbage to fim ... # find $DIR/ -type f -iname '*.jpg' -or -iname '*.jpeg' -or -iname '*.png' -or -iname '*.gif' -or -iname '*.bmp' -or -iname '*.tiff' | sort -n | $FBI $fbiopts -- - cd ${DIR}/* ; ${zgvpre:=:} ; ${zgvpost:=:} $( sudo $ZGV $zgvopts ) ; sudo /bin/rm -fr .xvpics/*; sudo /bin/rmdir .xvpics # when no framebuffer device is available, we could invoke another console viewer, couldn't we ? # cacaview $DIR/* # the old syntax # $FBI $fbiopts -P `find $DIR -iname '*.png' -or -iname '*.jpg' -or -iname '*.gif' -or -iname '*.jpeg' -or -iname '*.tiff' -or -iname '*.bmp'` # or the older one .. #$FBI $fbiopts -P -- $files # or the ancient one #fbi $fbiopts -P $DIR/ps*.tiff -- System Information: Debian Release: squeeze/sid APT prefers testing APT policy: (990, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.30-2-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages zgv depends on: ii libc6 2.11.2-6 Embedded GNU C Library: Shared lib ii libjpeg62 6b1-1 The Independent JPEG Group's JPEG ii libpng12-0 1.2.41-1 PNG library - runtime ii libsvga1 1:1.4.3-29 console SVGA display libraries ii libtiff4 3.9.2-1 Tag Image File Format (TIFF) libra ii zlib1g 1:1.2.3.3.dfsg-15 compression library - runtime zgv recommends no packages. zgv suggests no packages. -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org