14

I have already read the question about Creating .desktop files to use on the "Open with other application" tab but this is not what I want, I want to be able to click on the file in Dash or in Nautilus and be able to open it with the specified app.

For example I have this case right now:

When I click on an EXE file it does not get executed by Wine, instead I get the following:

enter image description here

If I try to look for Wine in the Open With context menu option it is there. I am fine executing it from there the first time, but then the following times Wine does not appears selected in the main Context menu:

enter image description here

I then went to Properties to the Open With Tab to look for Wine. It was not in the Default apps nor was it in the Recommended ones when I clicked and search on Show other applications

enter image description here

This is not limited to EXE extensions. It also has happened with MKV files, MP4 files, JPG, PNG, MP3 and even SVG and CSS. So instead of trying to find a way of solving it for one, I want a way that can be done to any type of extension that can:

  • Make the app the default of that extension
  • Appear on the context menu in Nautilus when I right click on the file
  • Appears on the "Open With" tab on the Property window of the file
  • Correctly executes the specified app when I click on the file with Dash

This might sound like it should be common sense for an app to execute the file but it does not always work like that. So for the cases where it actually does not work, how to fix it. A reset of the extension?, An update of the files that can open said extension?, an addition of the app via a command line or GUI tool?

6
  • Have a look at askubuntu.com/a/189284/41499 it uses Ubuntu Tweak Jan 6, 2013 at 20:02
  • Give me a moment to test it out. Although I was looking for a way that did not need to install a PPA. Something for example that was already IN Ubuntu. Jan 6, 2013 at 20:08
  • Can you add it as an answer, at least until a more "Ubuntu-ish" option comes along. It does change the app for the extension but I have a case where there is not internet. Jan 6, 2013 at 20:12
  • I feel bad just copying it, or should I just copy my comment to an answer? It would be nice to see what Ubuntu Tweak actually does, it makes some extra desktop files, but I don't know if it does anything extra... Jan 6, 2013 at 20:16
  • Found a better, more "Ubuntu-ish" option ;) Jan 6, 2013 at 20:28

2 Answers 2

17

You can use the command mimeopen, in a terminal go to the folder where your .exe file is and type

mimeopen -d filename.exe

You will get a popup menu, where you can see some options, but there is also an option 'Other...', choose this one, then type the command which you would use if you would open the file in the terminal and replace the filename with %f. So in this case you would type wine %f.

Now the default association for all exe files should be changed to wine.

Alternative, using Ubuntu-Tweak as described in Change all associations from gedit to another application will also change the default app associated.

6
  • 1
    Great answer. I used this same approach for .mp4 to change the video player.
    – Elder Geek
    Mar 6, 2015 at 16:59
  • The use of mimeopen is ok when desiring to use/create a custom command but if wishing to just set an app to be the default for a mimetype then r. click > properties > open with > pick app > click Set as default button is better.
    – doug
    Mar 6, 2015 at 17:53
  • 2
    @doug you're right, but the question is about what to do if the application is not in that list (which happens a lot). Mar 6, 2015 at 19:26
  • How do you make that process in one line ? I have a script and i want to set .exe to wine %f, .vlc to vlc %f etc... It is possible to do it in a bash script ? thanks
    – Ugo Hed
    Apr 5, 2016 at 15:58
  • Reading the man page (man.cx/mimeopen) I don't you can unfortunately. Apr 6, 2016 at 5:43
0

In Ubuntu 21.10 (and probably all other distros using GNOMES File Manager Nautilus) you can also open files (Nautilus) -> click on the file -> Properties -> Open With -> Select the desired Application -> Set as Default.

enter image description here

Mind however, that file extension are not how GNOME determins with what programm to open a file, but based on file type (Better explained here).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .