Opening mutt’s HTML attachments with epiphany?

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 thoughts on “Opening mutt’s HTML attachments with epiphany?

  1. 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. 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. 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. Ok, found the reason for the “user agent has changed” problem. It was caused by an option in the Comment Timeout plugin.

  5. 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. 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. 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. 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.

Comments are closed.