<SOLVED> Is it possible/how could I change default software launcher for specific file extensions through the terminal?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
d186
Level 1
Level 1
Posts: 3
Joined: Sat Mar 23, 2024 12:06 pm

<SOLVED> Is it possible/how could I change default software launcher for specific file extensions through the terminal?

Post by d186 »

Is there a terminal command for me to change the default software for launching specific file extensions or not recommendable/only possible through the desktop environment?
Last edited by d186 on Sat Mar 23, 2024 5:27 pm, edited 1 time in total.
User avatar
xenopeek
Level 25
Level 25
Posts: 29615
Joined: Wed Jul 06, 2011 3:58 am

Re: Is it possible/how could I change default software launcher for specific file extensions through the terminal?

Post by xenopeek »

Yes, there is a 2 step process:

1) First you have to find out the MIME type for file with that extension. Open a terminal in a directory where you have such a file and run the command xdg-mime query filetype filename where you replace "filename" with the filename. You can press Tab key to auto-complete partially typed filenames. The command will reply the MIME type of the file.

2) Then find the .desktop file for the program you want to set as default. You can usually find them in /usr/share/applications and by checking the files list of the program's package and getting the name of the .desktop file from that. Then you can run xdg-mime default application mimetype where you replace "application" with the name of the .desktop file (just its filename, not the path) and "mimetype" with the MIME type you got in step 1.

You can see the current default with xdg-mime query default mimetype where your replace "mimetype" with the MIME type you got in step 1.
Image
d186
Level 1
Level 1
Posts: 3
Joined: Sat Mar 23, 2024 12:06 pm

Re: Is it possible/how could I change default software launcher for specific file extensions through the terminal?

Post by d186 »

Thank you, xenopeek!!
Post Reply

Return to “Beginner Questions”