NovaSquirrel / Mesen-X

Mesen X is a cross-platform (Windows & Linux) NES/Famicom emulator built in C++ and C#. This fork is meant to gather development efforts from different forks. Deprecated; see https://github.com/SourMesen/Mesen2/
https://www.mesen.ca
GNU General Public License v3.0
161 stars 29 forks source link

Unable to set persistent rom file associations on Linux #136

Open pgattic opened 1 year ago

pgattic commented 1 year ago

First of all, I really appreciate this emulator as it has served me well in debugging and romhacking for years, wanted to extend my gratitude.

However, on Linux with KDE desktop environment I have run into this issue where I am unable to consistently run my NES ROMs through Mesen by double-clicking them. I go into the default applications settings, and set Mesen to the NES ROM default application, and it works once, but then the file association disappears the next time I run Mesen. This has happened to me on both Ubuntu and Pop!_OS running KDE (on two separate computers) and I can shortly test it on GNOME too.

Steps to reproduce (on Linux):

  1. Set x-nes-rom file association to Mesen (could be done through Mesen's app launch settings, through the system settings, or through clicking any ".nes" ROM).
  2. Run Mesen and close it
  3. See that the next time you try to run a .nes file through doubleclick or xdg-open, it says there is no associated app

I have a feeling this problem is related to Mono, does anyone else know of other mono-compatible Windows apps that have a similar problem? And more importantly, does anybody have a workaround?

pgattic commented 1 year ago

Okay just realized the source of the issue, it is because the ".desktop" file (found in ~/.local/share/applications) for Mesen is renamed every time the app is launched, as it gets this weird string of characters in its name. Since xdg's file associations are made by reference to ".desktop" files, renaming these breaks the association. I don't know if this renaming is related to Mono or to Mesen, but it is still kind of annoying.

But still, I am looking for solutions. Anyone know how to solve this problem?

pgattic commented 1 year ago

Found the source of the problem. Just made a PR for some suggested fixes. But I am only so sure that it won't cause issues somewhere else.

But in the meantime, I have a hacky solution for anyone else who is desperate to make file associations to Mesen in Linux. This does solve the problem, but has an annoying side effect.

  1. Make a copy of the file "mesen.[RandomNumbersAndLetters].desktop" found in ~/.local/share/applications, and rename it to just "mesen.desktop"
  2. Run xdg-mime default ~/.local/share/applications/mesen.desktop x-nes-rom from the command line

Side effect: Mesen will now have two entries in your apps list and start menu. Both shortcuts work the same, but its a bit annoying to have both.