Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6476901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:52:57+00:00 2026-05-25T06:52:57+00:00

In Linux, is there a way to ask any xdg services, or gtk services,

  • 0

In Linux, is there a way to ask any xdg services, or gtk services, which application is the default application for a given file?

I realize that xdg-open 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.

On OSX I can use LaunchServices for this:

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

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:52:57+00:00Added an answer on May 25, 2026 at 6:52 am

    Even better I found the official gnome way to do this.

    import gio
    mime_type = gio.content_type_guess('foo.txt')
    app_infos = gio.gio.app_info_get_all_for_type(mime_type)
    for app_info in app_infos:
        print app_info.get_name(), app_info.get_executable(), app_info.get_icon()
    # pure bliss
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to store file creation time in linux? May be filesystem
Using UNIX socket APIs on Linux, is there any way to guarantee that I
Is there any way under linux/terminal to count, how many times the char f
Is there a way in Windows/Linux or any other operating system to know at
Is there a way to generate Excel spreadsheets with Perl on Linux so that
Is there any way find difference between two cs files. I already ask question
I see here: http://www.pgrs.net/2008/1/11/command-line-clipboard-access that there's a way in linux and osx to copy
Is there any way to execute Linux commands with c without using execlp() ,
Is there any way to read the System's (Linux, Windows, OS/X etc) volume with
Is there a way to encrypt or enclose my code on my Linux server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.