Add “open with DOSBox” option in Nautilus

I was looking for a way to add a custom “open with” option so that I could use nautilus to navigate to my game folder then open a .conf file with DOSBox and have it exit when finished. To do that you would create /home/user/.local/share/applications/dosbox.desktop then add the following contents:


[Desktop Entry]
Name=dosbox
GenericName=DOSBox DOS Emulator
Comment=Play the moldy oldies
Keywords=Plaintext;Write;
Exec=gnome-terminal -e dosbox -conf %U -exit
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;
Icon=/usr/share/app-install/icons/dosbox.png
Categories=GNOME;GTK;System;
X-GNOME-DocPath=gedit/gedit.xml
X-GNOME-FullName=DOSBox
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=dosbox
X-GNOME-Bugzilla-Component=general
X-GNOME-Bugzilla-Version=3.4.1
X-GNOME-Bugzilla-ExtraInfoScript=/usr/share/gedit/gedit-bugreport
Actions=Window;Document;
X-Ubuntu-Gettext-Domain=dosbox

[Desktop Action Window]
Name=Open a New Window
Exec=gedit --new-window
OnlyShowIn=Unity;

[Desktop Action Document]
Name=Open a New Document
Exec=gedit --new-window
OnlyShowIn=Unity;

 

Adding -exit in the command string enables DOSBox to exit properly when launched this way. I had tried just having "exit" added to the .conf but that didn't actually close the parent window. The reason to execute it from gnome-terminal is two fold, the first reason is that you have a terminal you can see dosbox backend info in case of a problem, the second reason is that when using Unity in Ubuntu if you don't execute through gnome-terminal then you don't get an icon on the launch bar.