<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>therning.org/ magnus &#187; mutt</title>
	<atom:link href="http://therning.org/magnus/archives/tag/mutt/feed" rel="self" type="application/rss+xml" />
	<link>http://therning.org/magnus</link>
	<description>Incoherent mumblings</description>
	<lastBuildDate>Wed, 17 Mar 2010 00:39:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mutt and GNOME MIME types</title>
		<link>http://therning.org/magnus/archives/251</link>
		<comments>http://therning.org/magnus/archives/251#comments</comments>
		<pubDate>Fri, 26 Jan 2007 13:51:16 +0000</pubDate>
		<dc:creator>Magnus</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[mailcap]]></category>
		<category><![CDATA[mime types]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[muttng]]></category>

		<guid isPermaLink="false">http://therning.org/magnus/archives/251</guid>
		<description><![CDATA[A little while ago I wanted to launch an OGG file attached to an email. Since I read email in Mutt and it does such an excellent job of delegating unknown MIME types to external applications I simply pressed v (to see the attachments), selected the OGG attachment and pressed enter. Realplayer launched! Imagine my [...]]]></description>
			<content:encoded><![CDATA[<p>A little while ago I wanted to launch an OGG file attached to an email. Since I read email in Mutt and it does such an excellent job of delegating unknown MIME types to external applications I simply pressed <code>v</code> (to see the attachments), selected the OGG attachment and pressed <code>enter</code>. Realplayer launched! Imagine my surprise.</p>

<p>After purging Realplayer from my system I had an idea. Mutt uses <code>mailcap</code> to determine how to deal with MIME types it can&#8217;t display, but since I&#8217;m using GNOME and it has a different system to deal with MIME types I frequently am surprised when viewing attachments in Mutt. Isn&#8217;t there some way of combining the two? Well, I frequently use <code>gnome-open</code> to launch viewers from the command line. But it forks off a new process for the viewer so it can&#8217;t be used in <code>mailcap</code><sup>i</sup>. I spent some time looking into the inner workings of <code>gnome-open</code> and it might be possible to hack it to add a command line option to make it wait for the viewer to exit. However my quick test using Python suggests that it&#8217;d require changes in the underlying libraries<sup>ii</sup>.</p>

<p>From what I learned looking through the implementation of <code>gnome-open</code> I hacked together the following short Python script:</p>

<pre><code>#! /usr/bin/env python

import gnomevfs
import os
import sys

mime_type = gnomevfs.get_mime_type(sys.argv[1])
mime_app = gnomevfs.mime_get_default_application(mime_type)
application = os.popen('whereis %s' % mime_app[2]).readline().split(' ')[1]

os.execl(application, application, sys.argv[1])
</code></pre>

<p>Then I added a line to the top of <code>~/.mailcap</code>:</p>

<pre><code>application/*; ${HOME}/bin/gnopen '%s'; test=test -n "$DISPLAY"
</code></pre>

<p>Works like a charm, but of course suggestions/improvement are welcome!</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://digg.com/submit?phase=2&amp;url=http://therning.org/magnus/archives/251&amp;title=Mutt and GNOME MIME types' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://therning.org/magnus/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://therning.org/magnus/archives/251&amp;title=Mutt and GNOME MIME types' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://therning.org/magnus/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a>  <a title='See more bookmark and sharing options...' href='http://therning.org/magnus/archives/251#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div><ol class="footnotes"><li id="footnote_0_251" class="footnote">It seems Mutt removes the temporary file as soon as the viewer returns, so if <code>gnome-open</code> forks and exits Mutt will delete the file before the actual viewer gets to load it. Bugger.</li><li id="footnote_1_251" class="footnote">I traced it down to a call to <code>g_spawn_async</code> that should be changed to <code>g_spawn_sync</code>, but that&#8217;s deep down in the underbelly of GNOME-VFS.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://therning.org/magnus/archives/251/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tagging in mutt? Yes, please!</title>
		<link>http://therning.org/magnus/archives/194</link>
		<comments>http://therning.org/magnus/archives/194#comments</comments>
		<pubDate>Mon, 11 Sep 2006 09:31:19 +0000</pubDate>
		<dc:creator>Magnus</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[tagging]]></category>

		<guid isPermaLink="false">http://therning.org/magnus/archives/194</guid>
		<description><![CDATA[madduck, I&#8217;ve also been missing tagging and virtual folders. Mairix I see as a search tool, not something I&#8217;d like to use to force virtual folders onto mutt. I did use Gnus for a while, years ago, but nowadays it&#8217;s a no-no for me&#8212;I saw the light and switched from Emacs to Vim.
   [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.madduck.net/geek/2006.09.08_mutt-tagging">madduck</a>, I&#8217;ve also been missing tagging and virtual folders. <a href="http://www.rpcurnow.force9.co.uk/mairix/">Mairix</a> I see as a search tool, not something I&#8217;d like to use to force virtual folders onto mutt. I did use <a href="http://www.gnus.org/">Gnus</a> for a while, years ago, but nowadays it&#8217;s a no-no for me&#8212;I saw the light and switched from Emacs to Vim.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://digg.com/submit?phase=2&amp;url=http://therning.org/magnus/archives/194&amp;title=Tagging in mutt? Yes, please!' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://therning.org/magnus/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://therning.org/magnus/archives/194&amp;title=Tagging in mutt? Yes, please!' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://therning.org/magnus/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a>  <a title='See more bookmark and sharing options...' href='http://therning.org/magnus/archives/194#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://therning.org/magnus/archives/194/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
