[gnome-love] Mutt and GNOME MIME, a better solution?



The other day I got tired of trying to maintain in effect two sets of
MIME-type-to-application settings, GNOME's and mailcap.  I first tried
using gnome-open, but it spawns a new process for the application and
mutt removes the temporary file as soon as the handler returns, so by
the time the handler was started the file to handle was already gone.

I ended up writing up a little Python script, but I'm not sure if
there's an easier way of achieving this (e.g. syncronising GNOME MIME
and mailcap).

Here's the script:

  #! /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])

Any comments on this?

/M

I did blog about it here: http://therning.org/magnus/archives/251

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus therning org             Jabber: magnus therning gmail com
http://therning.org/magnus

Attachment: pgpelDvVYQCvs.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]