[SOLVED] command to change default application to open file

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.
Locked
afora
Level 4
Level 4
Posts: 237
Joined: Mon Aug 26, 2019 7:35 pm

[SOLVED] command to change default application to open file

Post by afora »

I know how to change it via GUI - the interface is pretty familiar to Windows.

However, I searched and struggled to find to do this programmatically as a script command. Can anyone suggest a way? I'm trying to associate Mirage with all image filetypes.

Many thanks!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: command to change default application to open file

Post by Flemur »

afora wrote: Sat Oct 12, 2019 5:39 pm I know how to change it via GUI - the interface is pretty familiar to Windows.
However, I searched and struggled to find to do this programmatically as a script command. Can anyone suggest a way? I'm trying to associate Mirage with all image filetypes.
Many thanks!
I bet one of these commands might do it!

Code: Select all

gvfs-mime
mimeopen
mimetype
update-mime
update-mime-database  (edit: pretty sure not this one)
xdg-mime
xfce4-mime-settings (xfce4 only?)
xdg-mime
You might also look at adding/modifying some text to/in:

Code: Select all

~/.config/mimeapps.list
...like cat a file of new defaults onto the end...but I'll bet right now that that's too easy. (The file is divided up into segments)
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
afora
Level 4
Level 4
Posts: 237
Joined: Mon Aug 26, 2019 7:35 pm

Re: command to change default application to open file

Post by afora »

I'm new to Linux, and I'm not quite sure how to use any of those...

Can you suggest a complete command which will take care of this?

Tu!
WharfRat

Re: command to change default application to open file

Post by WharfRat »

Open the file ~/.config/mimeapps.list with the text editor.

Search for image - you'll find bmp, gif, jpeg, png and tiff e.g., image/gif=xviewer.desktop

Change xviewer to mirage :wink:
afora
Level 4
Level 4
Posts: 237
Joined: Mon Aug 26, 2019 7:35 pm

Re: command to change default application to open file

Post by afora »

That's fantastic, thank you for your help.

Just curious - as this is only for images - is it possible to change associated application with other file types? Say, mp3s? Or text files? Or an arbitrary file type?
WharfRat

Re: command to change default application to open file

Post by WharfRat »

afora wrote: Tue Oct 29, 2019 10:16 pm That's fantastic, thank you for your help.

Just curious - as this is only for images - is it possible to change associated application with other file types? Say, mp3s? Or text files? Or an arbitrary file type?
You can try the lines that start with audio and video or add one for mp3 since there isn't one there.

Not sure about the others

You know there is a preferred applications dialog :?:
Screenshot at 2019-10-29 22-28-08.png
Screenshot at 2019-10-29 22-28-08.png (32.79 KiB) Viewed 1827 times
John Thompson
Level 1
Level 1
Posts: 32
Joined: Thu Jan 29, 2015 8:36 am

Re: [SOLVED] command to change default application to open file

Post by John Thompson »

Just installed easytag. Now .opus files open in EasyTag not VLC (as I usually have it).
mimeapps.list is unchanged and still points to VLC.
Found that the easy way to correct this is to right-click the file in Nemo, select: Open With - Other Application, select the application (VLC in this case), then "Set as default".
Now works correcty. So mimeapps.list can't be the only place where this info is stored.
[Double Solved]!!
afora
Level 4
Level 4
Posts: 237
Joined: Mon Aug 26, 2019 7:35 pm

Re: [SOLVED] command to change default application to open file

Post by afora »

I believe that manual file association as you are describing would be automatically reflected in `mimeapps.list`. You may either need to restart your system or run a update command on this first to see it.
Locked

Return to “Beginner Questions”