Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix xdg-mime default registration #227

Merged
merged 5 commits into from
Aug 7, 2024
Merged

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Jul 4, 2024

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 ...

  • 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?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jul 4, 2024
@jaimergp jaimergp marked this pull request as ready for review July 5, 2024 08:15
@jaimergp jaimergp requested a review from a team as a code owner July 5, 2024 08:15
@jaimergp
Copy link
Contributor Author

jaimergp commented Jul 5, 2024

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

@mrclary
Copy link

mrclary commented Jul 16, 2024

@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

@jaimergp
Copy link
Contributor Author

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?

@mrclary
Copy link

mrclary commented Jul 16, 2024

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.

@jaimergp
Copy link
Contributor Author

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

Copy link
Contributor

@marcoesters marcoesters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think that this is PR is very useful: the documentation is clearer now and a subprocess call was replaced with a simple parser using only the standard library. To me, that's a win.

Just one small comment.

menuinst/platforms/linux.py Outdated Show resolved Hide resolved
@jaimergp jaimergp merged commit 145bb74 into conda:main Aug 7, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Cannot set Spyder as default application for .py files on Linux
4 participants