Sample Header Ad - 728x90

How can I run a .desktop file?

14 votes
2 answers
26384 views
I'm trying to write a script that launches the default application for a given mime type. For example, I would like to say my-script text/plain and have it open KWrite for me. What I know is that you can use xdg-mime to query what is the default application for a given mime type $ xdg-mime query default text/plain org.kde.kwrite.desktop However, I don't know what is the command I can use to launch KWrite given org.kde.kwrite.desktop. How can I do that? Is having the name of the desktop file enough or do I also need to find out where it is stored (/usr/share/applications, .local/share/applications, etc)? ------- By the way, I don't think I can solve my original problem using xdg-open because XDG open expects to receive a filename or URL as a parameter and I want to be able to launch my applications without needing to pass a filename. For example, I want to be able to open the text editor on a blank file buffer or open my web browser on its home page.
Asked by hugomg (6057 rep)
Aug 25, 2016, 08:00 PM
Last activity: Jul 17, 2025, 04:42 PM