Opening mutt’s HTML attachments with epiphany?

August 22nd, 2007 by lucas

I just ran into a rather funny problem. I’d like to use epiphany to open text/html attachments or mail parts.

Mutt uses mailcap, so I added an entry in ~/.mailcap:
text/html; epiphany-browser '%s'; description=HTML Text; nametemplate=%s.html

This should work fine, but the problem is that mutt creates a temporary file (/tmp/mutt.html) and removes it when the command terminates, which is nearly immediately with epiphany. And epiphany has a really nice feature: it monitors local files for changes and reload them when they change. Which results in seeing the page briefly, then a File "/tmp/mutt.html" not found. error page.

Anyone using mutt and epiphany together successfully?

8 Responses to “Opening mutt’s HTML attachments with epiphany?”

  1. Anonymous wrote on 08/22/07 at 8:36 pm :

    Random idea: you could write a short script to take an HTML file and transform it into a data URI, then pass that to epiphany. Better idea: make epiphany’s remote mechanism not exit until you stop viewing the file. Another idea: make epiphany’s reload functionality not go to an error page if the file disappears, just add a status message somewhere.

  2. Simon Ward wrote on 08/23/07 at 12:08 am :

    You can add the needsterminal flag to your mailcap entry. By default mutt will require you to press a key after launching the browser before it gets on with removing the temporary file:

    text/html; epiphany-browser '%s'; description=HTML Text; nametemplate=%s.html; needsterminal

    PS. When using Epiphany to submit a comment an error occurs claiming the user agent has changed since viewing the page.

  3. Anonymous wrote on 08/23/07 at 12:48 am :

    Yeah, same problem submitting a comment with Firefox. For some reason it works if I open a new tab, paste in the URL, and then paste in my comment.

  4. lucas wrote on 08/23/07 at 7:21 am :

    Ok, found the reason for the “user agent has changed” problem. It was caused by an option in the Comment Timeout plugin.

  5. Ismael Valladolid Torres wrote on 08/23/07 at 8:52 am :

    This happens constantly if you try to use a Cygwin version of Mutt on Windows. Kind of this could work:

    text/html; cp ‘%s’ /tmp/blah.html && epiphany-browser ‘/tmp/blah.html’ && rm -f /tmp/blah.html; nametemplate=%s.html

  6. martin wrote on 08/23/07 at 11:31 am :

    I usually use pipe attachment to view things in X11 apps, but the following script shouldn’t be hard to adopt for mailcap usage…

    #! /bin/bash

    TMPFILE=$(mktemp ~/tmp/pwrap.XXXXXX) || exit 1

    cat > $TMPFILE

    ($* $TMPFILE; rm $TMPFILE) < /dev/null > /dev/null 2>&1 &
    disown

    i have this script as pwrap in my path and use it as
    pwrap dillo

    (I hope i quoted correctly for the blog)

  7. Stephen Touset wrote on 08/23/07 at 4:40 pm :

    Funny nobody thought of the obvious solution: check “epiphany -h”. I ran into a similar (but unrelated) issue that was rooted in the same problem with epiphany just yesterday.

    Running “epiphany -p” opens a “private” instance of Epiphany which doesn’t try and join with an existing open window. The command won’t terminate until the browser is actually closed.

    Much simpler than writing shell script wrappers, etc.

    Hope that helps.

  8. Magnus wrote on 08/24/07 at 4:18 pm :

    I ran into a similar issue when I wanted to use only one set of preferred applications (GNOME’s) rather than two (GNOME’s and mailcap). Here‘s the post I wrote afterwards.

    I’d love pointers on how to improve my configuration.