title: Find the default application name for a given file
body: <p>In Linux, is there a way to ask any xdg services, or gtk services, which application is the default application for a given file?</p>
  
  <p>I realize that <strong>xdg-open</strong> will in fact, launch the correct application.  However, I want to be able to display the application's name in a context menu.  So that when the user clicks on the menu item, it will then launch xdg-open, which will launch that app.</p>
  
  <p>On OSX I can use LaunchServices for this:</p>
  
  <pre><code>def getDefaultDarwinApplication(path):
      import LaunchServices
      import CoreData
      import urllib
  
      url = CoreData.CFURLRef.URLWithString_("file://"+urllib.quote(path))
      os_status, app_ref, appurl = LaunchServices.LSGetApplicationForURL(url, LaunchServices.kLSRolesAll, None, None)
      if os_status != 0:
          return ""
      apppath = app_ref.as_pathname()
      name = os.path.basename(apppath).replace(".app", "")
      return name
  </code></pre>
  
  <p>The hope is that there is something similar on Linux I can use.  A builtin python module would be best, but even screen scraping would work.</p>