Setting up WINE - How to open exe files with WINE automatically on Ubuntu 17.04 with Gnome3

After I installed Ubuntu on my laptop, one of the first setup tasks was to install WINE. WINE, originally short for Wine Is Not an Emulator, is a, well, not an emulator, but a way to run Windows programs on Ubuntu. It has something to do with mapping machine instructions from the Windows version to the Linux equivalents, or something like that. Maybe they came up with that name as a joke about real wine. A long time ago, someone might have suggested that it would be nice if Windows software could be coerced to run on Ubuntu. And someone else might have asked him how much he had had to drink. Okay, Okay. Now you're wondering how much I had to drink. I guess people used to hate emulators. To be honest they're not so bad now, but when the WINE project started they were considerably worse.

Why was that high on my list of initial setup tasks? I don't know that either. I plan to use Windows 10 for games anyway, where they are better supported. At the time when I was figuring this out, I was trying to run Game Maker Studio, which I got for almost free from this humble bundle. Unfortunately, it turned out that GMS and WINE really don't play nicely together anyway (I wound up using a VM), but I wanted to get WINE configured the way I felt it should be before I tried it and found that out. That is, I wanted a double click on any .exe to open it in WINE by default.

I right clicked on my Game Maker installer file and hit Open With Other Application.

GNOME Select Application Window
WINE is nowhere to be found

If I remember correctly, Unity let you find an application anywhere in the filesystem... Gnome appears to be different, more complicated in the name of simplicity. My first thought (possibly influenced by search results ;) )was to add a .desktop file somewhere and register WINE as an application which I could possibly choose to open .exe files with. After a bit of googling, I came up with this .desktop file, which I saved as ~/.local/share/applications/wine.desktop:

[Desktop Entry]
Name=Wine
Comment=Run Windows Applications
Exec=wine
Terminal=false
Icon=wine
Type=Application
Categories=Utility;
NoDisplay=true

Originally I didn't have that last line, and WINE showed up in the gnome launcher, but it didn't do anything and didn't show up in the other application menu, so I added that line to hide the useless link from the launcher.

Back to square one - this method was almost failing. I decided to try finding out what happened if I set the default to some random other app - where would that be saved, and how could I switch it to use WINE?

Then I noticed a file called ~/.local/share/applications/mimeapps.list, which had this in it:

[Default Applications]
x-scheme-handler/jetbrains=jetbrains-toolbox.desktop
text/html=google-chrome.desktop
x-scheme-handler/http=google-chrome.desktop
x-scheme-handler/https=google-chrome.desktop
x-scheme-handler/about=google-chrome.desktop
x-scheme-handler/unknown=google-chrome.desktop

Hmmm... Default applications based on mime types? I googled the mime for exe files and came up with this: application/x-ms-dos-executable. So I added this line to the mimeapps.list:

application/x-ms-dos-executable=wine.desktop

And then I right clicked on the Game Maker Studio Installer, and Lo and Behold!

Default Open With Application for .exe shows WINE
It Works!

Then I ran the installer and yoyo complained about missing some core Windows feature, so I had to use a Windows VM anyway. But now I'm set up properly in case I stumble upon other executables. Great!

I have no idea if anyone else like opening .exe files in a hex editor by default or something. I mean seriously, is there any other way I'd want to open .exe files on a linux machine? WINE should totally have done that automatically!