On Tue, Jan 30, 2001 at 11:59:03AM -0500, Dan Boger wrote:
> On Tue, Jan 30, 2001 at 08:47:20AM -0800, Ben Reser wrote:
> > Not possible right now.  urlview only knows how to use one program.  You can
> > use the COMMAND option in the .urlview file to change from netscape to another
> > program but you can set one for ftp and one for http...
> 
> unless you write a wrapper script, put it as your COMMAND, and have it
> check if it's an ftp url, or a https? url, or whatever...
> 

Here's what i do.

1. in my ~/.muttrc i have 
    macro index <F9> |urlview\n 'extract web URLs and goto'
    macro pager <F9> |urlview\n 'extract web URLs and goto'

2. in my ~/.urlview i have
    COMMAND choose_web_vwr.sh '%s'

3. the script choose_web_vwr.sh asks the user whether to use
   netscape, lynx, wget etc. with appropriate defaults depending
   on file extension and whether http is found etc..   See
   attachment for the script.


-- 
Disclaimer:  These are my opinions, not those of my employer
Gerald K. Embery ;                          e-mail: [EMAIL PROTECTED]
Bureau of Meteorology Research Centre,  
Melbourne, Australia ;       http://www.bom.gov.au/  bmrc/medr/gke.html
#!/bin/ksh
# choose whether to use netscape/lynx/...

while test $# -gt 0
do
    if `RunningX`
    then
        reply='x'
        case $1 in
        # piccy files to be viewed with Netscape
         *.jpg|*.jpeg|*.gif|*.png)
            openin='N'
            opentype='openFile'
            ;;
        # files to be downloaded (probably)
         *.gz|*.tgz|*.tar|*.bz2|*.Z|*.rpm|*.deb)
            openin='g'
            opentype='openURL'
            ;;
         http://*)
            openin='n'
            opentype='openURL'
            ;;
         www.*)
            openin='n'
            opentype='openURL'
            ;;
         ftp://*)
            openin='n'
            opentype='openURL'
            ;;
         ftp.*)
            openin='n'
            opentype='openURL'
            ;;
         /tmp/*)
            openin='k'
            opentype='openFile'
            ;;
         /scratch*/*)
            openin='k'
            opentype='openFile'
            ;;
         *.html)
            openin='n'
            opentype='openFile'
            ;;
         *.htm)
            openin='n'
            opentype='openFile'
            ;;
         *)
            openin='n'
            opentype='openFile'
            ;;
        esac

        #set -vx
        filename=$1 

       # if a file, do we need to fill out with pathname? 
        if test "${opentype}" = 'openFile' 
        then
            case $1 in
             /*)
               # full path provided ... good.
                if test -f $1
                then
                    filename=${1}
                fi
                ;;
             *)
               # not full path name,
               # can we fill in with current working directory ?
                if test -f `pwd`/$1
                then
                    filename=`pwd`/${1}
                else
                    echo "File not found - searching in FINDPATH for possibles"
                   # check all our paths  
                    tempfile=/scratch0/ch.$$
                    fncd $1 > $tempfile
                    vim -c "echo 'remove those you were NOT after'" $tempfile
                    filename=`cat $tempfile`
                    rm $tempfile
                fi
                ;;
            esac
        fi
        #set +vx

        if test "${openin}" = 'n'
        then
            echo -n "Netscape/Lynx/W3m/linKs (n,l,w,k)[$openin]:"
        elif test "${openin}" = 'N'
        then
           # here a (direct) file has been given only suitable for Netscape.
            set -vx
            (netscape -iconic -noraise -remote "${opentype}($filename)" || netscape 
-install -iconic "$filename") &
            set +vx
shift
if test $# -gt 0
then
    sleep 20   # this is to allow netscape time between several images 
fi
continue
        else
            echo -n "Netscape/Lynx/W3m/linKs/wGet/Text (n,l,w,k,g,t)[$openin]:"
        fi
        while [[ x$reply != x && $reply != [nlLwWkKgtq] ]]
        do
            read reply
            if test x"${reply}" != xq   #  q for quit
            then
                if test x"${reply}" = x
                then
                    reply=$openin
                fi
                if test "${reply}" = 'n'
                then
                    set -vx
                    (netscape -iconic -noraise -remote "${opentype}($filename)" || 
netscape -install -iconic "$filename") &
                    set +vx
                elif test "${reply}" = 'L'
                then
                    set -vx
                    /libraries0/bmrc/bin/color_xterm -title "Lynx $filename" -geometry 
100x30 -e /libraries0/bmrc/bin/lynx $filename &
                    set +vx
                elif test "${reply}" = 'l'
                then
                    set -vx
                    /libraries0/bmrc/bin/lynx $filename 
                    set +vx
                elif test "${reply}" = 'W'
                then
                    set -vx
                    /libraries0/bmrc/bin/color_xterm -title "w3m $filename" -geometry 
100x30 -bg wheat2 -fg black -bd orange -e /libraries0/bmrc/bin/w3m $filename &
                    set +vx
                elif test "${reply}" = 'w'
                then
                    set -vx
                    /libraries0/bmrc/bin/w3m $filename 
                    set +vx
                elif test "${reply}" = 'K'
                then
                    set -vx
                    /libraries0/bmrc/bin/color_xterm -title "links $filename" 
-geometry 100x30 -bg wheat2 -fg black -bd orange -e /libraries0/bmrc/bin/links 
$filename &
                    set +vx
                elif test "${reply}" = 'k'
                then
                    set -vx
                    /libraries0/bmrc/bin/links $filename 
                    set +vx
                elif test "${reply}" = 't'
                then
                    set -vx
                    /libraries0/bmrc/bin/lynx -dump -force_html $* | more 
                    set +vx
                elif test "${reply}" = 'g'
                then
                    set -vx
                    if [[ $(/bin/pwd) = */$USER/* ]]
                    then
                        /libraries0/bmrc/bin/wget $*
                    else
                        if test ! -d /scratch0/$USER
                        then
                            mkdir /scratch0/$USER
                        fi
                        /libraries0/bmrc/bin/wget --directory-prefix=/scratch0/$USER $*
                    fi
                    set +vx
                else
                    echo -n "??? dud reply. View using 
Netscape/Lynx/W3m/linKs/wGet/plainText/Quit? {L,W,K --> own xterm} 
(n,l,L,w,W,k,K,g,t,q)[$openin]:"
                fi
            fi
        done
    else
        /libraries0/bmrc/bin/lynx -dump -force_html $* | more
    fi

    shift
done

Reply via email to