#! /usr/bin/env python # From http://lwn.net/Articles/390679/ # taken from http://therning.org/magnus/archives/251 # $HOME/.mailcap should be: ''' application/*; mutt-mime-helper '%s'; test=test -n '$DISPLAY' image/*; mutt-mime-helper '%s'; test=test -n '$DISPLAY' audio/*; mutt-mime-helper '%s'; test=test -n '$DISPLAY' multipart/*; mutt-mime-helper '%s'; test=test -n '$DISPLAY' video/*; mutt-mime-helper '%s'; test=test -n '$DISPLAY' text/*; mutt-mime-helper '%s'; test=test -n '$DISPLAY' ''' import gnomevfs import os import sys to_open = sys.argv[1] print "opening %s" % to_open mime_type = gnomevfs.get_mime_type(to_open) 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])