* On 22 Jan 2015, Chris Green wrote:
> The trouble is I'm frequently seeing the temporary HTML file saved by
> mutt disappearing before firefox gets to see it, why does this happen
> sometimes (almost all the time now)? It used to work OK. I have just
> moved to a faster computer, would this affect it?
Yes, it's a race condition. Mutt removes the file when it regains
control of your terminal. /usr/bin/firefox is just a launcher - it will
detach and background the real firefox executable and come back to
mutt. If Firefox starts up slower than mutt finishes, the file will be
missing.
> text/html; /usr/bin/firefox %s
> text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html
To solve this you need a wrapper script around Firefox. The wrapper
will take the file content from $1 and save it somehow for Firefox, so
that mutt may delete the original.
There are various techniques for this. I personally like the approach
of hard-linking the temp file so that it doesn't use more storage.
Something like this:
#!/bin/sh
COPY="$1.firefox.html"
ln "$1" "$COPY"
/usr/bin/firefox "$COPY" &
But no matter what option you choose, your wrapper will then be
responsible for removing the saved copy! The only difference to not
having a wrapper at all is that now it doesn't matter how long you wait
to remove the extra copy, whereas with no wrapper the time that you wait
is the time that it takes to get mutt back. So something like this
should generally work. You can append it to the above.
# background a subshell to clean up later
(
sleep 120
rm "$COPY"
) &
> While I'm about it how do the two text/html entries in .mailcap work
> so that lynx is used by default but 'v' takes me to firefox?
I would think you've got it already. Mutt will only use a copiousoutput
entry for auto_view, and the first appropriate match otherwise. There
are a number of ways to control what "appropriate" means though; see
http://dev.mutt.org/doc/manual.html#advanced-mailcap
Are you seeing something different?
--
David Champion • [email protected]