X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=viewer.sh;fp=viewer.sh;h=0000000000000000000000000000000000000000;hb=6473993b691c6280c4ad1d1d9a3b697eb0e05eb2;hp=98682d45929611ccb7ac9f21dfd54c1ab6bb3ea7;hpb=5d1aa1fd3b6c8a003dd3789791a349f34a0b0c14;p=scripts.git diff --git a/viewer.sh b/viewer.sh deleted file mode 100755 index 98682d4..0000000 --- a/viewer.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/sh - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# This program is distributed in the hope that it will be useful, but # -# WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # -# General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -set -e - -function getgeometry () { - XSETUP="/tmp/xsetup" - - if [[ -f "${XSETUP}" ]]; then - - ACTIVE_SCREEN_GEOMETRY=($(awk '{ - if(0>= $5 && 0 < $5+$3) { print $2" "$3" "$4" "$5 } - }' < ${XSETUP})) - - ACTIVE_WIDTH=${ACTIVE_SCREEN_GEOMETRY[0]} - ACTIVE_HEIGHT=${ACTIVE_SCREEN_GEOMETRY[1]} - ACTIVE_X=${ACTIVE_SCREEN_GEOMETRY[2]} - ACTIVE_Y=${ACTIVE_SCREEN_GEOMETRY[3]} - - GEOMETRY="${ACTIVE_WIDTH}x${ACTIVE_HEIGHT}+${ACTIVE_X}+${ACTIVE_Y}" - fi -} - -# This is my universal file viewer - -# If no argument is given, we pick the most recent file - -if [[ ! "$1" ]]; then - file=$(\ls -tQ | head -1 | sed -e s/\"//g) - echo "Most recent is ${file}" - $0 "${file}" - exit 0 -fi - -# If there were arguments, we loop through them - -echo "Viewing $@" - -while [[ "$1" ]]; do - - file="$1" - - # file=$(\ls -tQd $1 | head -1 | sed -e s/\"//g) - - # if [[ ! -a "${file}" ]]; then - # echo "Can not find file $1" - # exit 1 - # fi - - type=$(file -L "${file}") - - case ${type} in - - *"FIG image text"*) - echo "${file}" - temp=$(mktemp /tmp/view.XXXXXX) - fig2dev -L pdf "${file}" ${temp} - # xpdf -g 800x600+8+8 ${temp} - getgeometry - xpdf -g ${GEOMETRY} ${temp} - rm ${temp} - ;; - - *"image"*) - echo "${file}" - # feh -g 800x600 "${file}" - getgeometry - feh -g ${GEOMETRY} "${file}" - ;; - - *"TeX DVI"*) - echo "${file}" - xdvi "${file}" - ;; - - # *"FIG image"*) - # echo "${file}" - # xfig "${file}" - # ;; - - *"PostScript"*) - echo "${file}" - gv "${file}" - ;; - - *"PDF"*) - echo "${file}" - # xpdf -g 800x600+8+8 "${file}" - getgeometry - xpdf -g ${GEOMETRY} "${file}" - ;; - - *"WAVE audio"*) - echo "${file}" - esdplay "${file}" - ;; - - *"MP3"*|*"MPEG"*|*"movie"*|*"video"*|*"AVI"*|*"Microsoft ASF"*) - mplayer -quiet "${file}" - ;; - - *" text"*) - HEIGHT=$(stty size | awk '{print $1}') - if [[ $(wc -l "${file}" | cut -f 1 -d' ') -gt $((HEIGHT-2)) ]]; then - less "${file}" - else - cat "${file}" - fi - ;; - - *"tar archive"*) - tar ztf "${file}" - ;; - - *"Microsoft Word Document"*) - antiword "${file}" | less - ;; - - *"directory"*) - echo ""${file}":"; ls -lt "${file}" - ;; - - *"gzip compressed"*) - temp=$(mktemp /tmp/view.XXXXXX) - echo "Decompressing to ${temp}" - zcat "${file}" > ${temp} - $0 ${temp} - echo "Removing ${temp}" - rm ${temp} - ;; - - *) - echo "Unable to handle ${type}" - ;; - - esac - - shift - -done