3 #########################################################################
4 # This program is free software: you can redistribute it and/or modify #
5 # it under the terms of the version 3 of the GNU General Public License #
6 # as published by the Free Software Foundation. #
8 # This program is distributed in the hope that it will be useful, but #
9 # WITHOUT ANY WARRANTY; without even the implied warranty of #
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
11 # General Public License for more details. #
13 # You should have received a copy of the GNU General Public License #
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
16 # Written by and Copyright (C) Francois Fleuret #
17 # Contact <francois@fleuret.org> for comments & bug reports #
18 #########################################################################
22 function getgeometry () {
25 if [[ -f "${XSETUP}" ]]; then
27 ACTIVE_SCREEN_GEOMETRY=($(awk '{
28 if(0>= $5 && 0 < $5+$3) { print $2" "$3" "$4" "$5 }
31 ACTIVE_WIDTH=${ACTIVE_SCREEN_GEOMETRY[0]}
32 ACTIVE_HEIGHT=${ACTIVE_SCREEN_GEOMETRY[1]}
33 ACTIVE_X=${ACTIVE_SCREEN_GEOMETRY[2]}
34 ACTIVE_Y=${ACTIVE_SCREEN_GEOMETRY[3]}
36 GEOMETRY="${ACTIVE_WIDTH}x${ACTIVE_HEIGHT}+${ACTIVE_X}+${ACTIVE_Y}"
40 # This is my universal file viewer
42 # If no argument is given, we pick the most recent file
45 file=$(\ls -tQ | head -1 | sed -e s/\"//g)
46 echo "Most recent is ${file}"
51 # If there were arguments, we loop through them
59 # file=$(\ls -tQd $1 | head -1 | sed -e s/\"//g)
61 # if [[ ! -a "${file}" ]]; then
62 # echo "Can not find file $1"
66 type=$(file -L "${file}")
72 temp=$(mktemp /tmp/view.XXXXXX)
73 fig2dev -L pdf "${file}" ${temp}
74 # xpdf -g 800x600+8+8 ${temp}
76 xpdf -g ${GEOMETRY} ${temp}
82 # feh -g 800x600 "${file}"
84 feh -g ${GEOMETRY} "${file}"
104 # xpdf -g 800x600+8+8 "${file}"
106 xpdf -g ${GEOMETRY} "${file}"
114 *"MP3"*|*"MPEG"*|*"movie"*|*"video"*|*"AVI"*|*"Microsoft ASF"*)
115 mplayer -quiet "${file}"
119 HEIGHT=$(stty size | awk '{print $1}')
120 if [[ $(wc -l "${file}" | cut -f 1 -d' ') -gt $((HEIGHT-2)) ]]; then
131 *"Microsoft Word Document"*)
132 antiword "${file}" | less
136 echo ""${file}":"; ls -lt "${file}"
140 temp=$(mktemp /tmp/view.XXXXXX)
141 echo "Decompressing to ${temp}"
142 zcat "${file}" > ${temp}
144 echo "Removing ${temp}"
149 echo "Unable to handle ${type}"