menuinst icon indicating copy to clipboard operation
menuinst copied to clipboard

Fix `xdg-mime` default registration

Open jaimergp opened this issue 1 year ago • 5 comments

Description

Closes #226. Instead of using xdg-mime default, we edit mimeapps.list manually. If an application is already registered as default, we won't override it. We always populate the "Added associations" list with our desktop file so it's there in the "open with" menu. We also handle cleanups now.

Checklist - did you ...

  • [x] Add a file to the news directory (using the template) for the next release's release notes?
  • [ ] Add / update necessary tests?
  • [ ] Add / update outdated documentation?

jaimergp avatar Jul 04 '24 19:07 jaimergp

@mrclary could you check if this PR fixes your Linux issues? Thanks!

jaimergp avatar Jul 05 '24 09:07 jaimergp

@jaimergp, sorry for the late follow up. I've been sick all last week. So a few observations with this branch:

  • Using the test JSON file I can reproduce your results and see FileTypeAssociation in the available applications list
  • Removing %f from the Linux platform command (i.e. import sys, pathlib as p; p.Path(r'__OUTPUT_FILE__').write_text(r'')) results in FileTypeAssociation not available in the applications list.
  • Removing MimeType and glob_patterns does not affect the result
  • Modifying the command in any way does not affect the result, as long as %f is somewhere in the command. e.g. "command": ["%f"] without MimeType or glob_patterns works

mrclary avatar Jul 16 '24 04:07 mrclary

Perfect! I'm reading this as "it works as long as %f is present in some way", so I added a note to the docs. In that case, I think this is ready to go, right?

jaimergp avatar Jul 16 '24 10:07 jaimergp

Okay, I'm a bit embarrassed. I was not aware of the %f requirement, and Spyder appears in the applications list even for menuinst=2.1.1 if %f is included in the command. I apologize for the inconvenience; perhaps this PR was not necessary. Nevertheless, everything seems to be working as expected.

mrclary avatar Jul 16 '24 15:07 mrclary

I did find a couple bugs and polished the cleanup, so no worries, it was indeed useful! Glad you made it work too.

jaimergp avatar Jul 16 '24 18:07 jaimergp