On 30Oct2011 07:42, Tim Johnson <t...@akwebsoft.com> wrote: | * Cameron Simpson <c...@zip.com.au> [111029 17:51]: | > The script is (was) wrong. withstdin was actually a differently purposed | > script and did exhibit that behaviour. | > | > I have modified it. Invoke the new version like this: | > | > text/html; withstdin --keep --ext=.html open -a Chrome <%s | | You D'Man Cameron! It works now. :) | | <..> | > I'm surprised you need a full path to withstdin if it is in your usualy | > stuff (as found by which, for example). You really should not need a | > full path for Chrome at all if it is a normal app. Unless its name isn't | > plain "Chrome" but something longer like "Google Chrome". Command-Tab | > should show the app names. | I mispoke. I don't need path for withstdin, but yes with Chrome | and yes the app name is "Google Chrome" | > Please refetch the updated script (realised my error after my earlier | > post, have been modifying the script meanwhile). | I've barely started my coffee here. I want to look further at your | script and see if it will work for image and video attachments.
Should do. The open-an-app mechanism is the same. However, as written withstdin leaves the temp copy lying around (the --keep mode). For HTML this won't waste much disc space by video will quickly get wasteful. I intend adding a --keep=N option to tidy up the temp file after N seconds, time for the app to open the file before tidyup. For images etc I have a more complex script: http://www.cskk.ezoshosting.com/cs/css/bin/apphelper which offers to view the attachment and also to save it, since I find the "open viewer, quit, ask to save" rigmarole tedious. It has a million switches (which you can put in $APPHELPER_PREOPTS to set default behaviour). Manual page here: http://www.cskk.ezoshosting.com/cs/css/manuals/apphelper.1.html Since apphelper finds the file viewer by consulting the mailcap file I in fact keep two such files around: a plain mailcap and a mailcap-ah which has lines like: image/jpg; ah %s xv; gui image/jpg; iminfo %s; copiousoutput which I use with mutt. As you can see I run apphelper via a small wrapper script "ah", which I attach below. It runs apphelper with the autoview mode on and has some conveniences, such as using the output of `xclip -o` if no filename is specified so I can X11-copy a URL and then run ah. Be warned that apphelper is like Apple's iTunes: the gateway drug to wanting a bunch of other scripts like view-unknown for files with a bad MIME type label, etc :-) Cheers, -- Cameron Simpson <c...@zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/ If you take something apart and put it back together again enough times, you will eventually have enough parts left over to build a second one. - Ayse Sercan <a...@netcom.com>
#!/bin/sh -u # # Run app-helper with the autoview mode on, defaulting to view-unknown. # - Cameron Simpson <c...@zip.com.au> 17dec2002 # cmd=$0 unlink= trace= ahopts= while [ $# -gt 0 ] do case "$1" in -u) unlink=1 ;; -[nyNYAX]) ahopts="$ahopts $1" ;; *) break ;; esac shift done if [ $# = 0 ] then if [ -n "$DISPLAY" ] then set -- "`xclip -o`" || exit 1 else echo "Usage: $cmd file [command [args...]]" >&2 exit 2 fi fi file=$1; shift $trace apphelper "$file" -y $ahopts ${1+"$@"} || exit 1 # unlink old copy? [ $unlink ] || exit 0 [ -s "$file" ] || exit 0 loc=`fileloc "$file"` || exit 1 [ "x$loc" = "x$file" ] && exit 0 exec rm -- "$file"