-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Implement file association Open a file from Finder/Explorer #2918
Conversation
This is awesome! Thanks for taking the time to do it. I'm all for having it register on install via NSIS, but I'm also thinking people might like to do it programmatically and be able to toggle it on or off as a preference setting. What are your thoughts on this? |
@leaanthony
As well, just tried to check if some other similar projects provide such feature – both electron and tauri are using installer approach. Also small remark about Linux: However I also think that this should be part of some installer like .deb that will creates Desktop Entry, file associations, check that webkit is installed etc. And also some uninstaller, that will clean up everything if application is removed. I don't know is there any plans to support installers for Linux (as this issue says no but it was 4 years ago #2), but will implement some bash prototype in example repo |
Thanks for taking the time to dive into that. Yeah, agree that the installer approach is probably better 👍 Good luck with the Linux side of things 😅 |
@leaanthony finally, I was able to achieve required result on Ubuntu. Updated PR description and test repo to demonstrate how this can be implemented. However as wails is not supporting now bundling for linux – nothing to add in this PR. Have just one question now – what is required for approving this PR? 🙃 If documentation is missing part, then maybe somebody can support me on this, so it will be added in proper place? |
Thanks for this. Please could you add an entry to the changelog located at I'd be keen to get feedback from @stffabi about the NSIS changes. Regarding documentation, I think the best solution might be a guide to walk developers through how to use it. |
@leaanthony changelog updated, documentation created as well. |
@leaanthony final changes were made:
Tested on all platform, works like a charm. BTW single instance lock branch is ready on my side for all the platforms :) Happy to open PR once this one will be merged :) |
I'll try to review this over the weekend 👍 |
Apologies for the delay on this. Will prioritise this |
Was able to test this one just to add some noise here from a noob, steps I followed and results:
|
Thank you for testing this PR. I didn't clearly understand this point:
Do you mean that only association for I tried now to add extra association in my branch and seems all extensions works correctly. If you will open Also please check that project.nsi is updated as well. It might be the case as you used it in existing project wails didn't update it. Check that Screen.Recording.2023-10-11.at.19.57.43.mov |
Hmm yep that's interesting. Ah I can see !insertmacro wails.associateFiles is not present in project.nsi for some reason, which is curious given 1 extension worked fine and the other only half updated correctly. To make sure I have an update CLI built, is it correct that I've cloned wails, run checkout for that PR:
Then built custom CLI with "go build -o wails-test". Anything else I can check/change that I might be missing as part of project configuration? |
@PylotLight try to copy project.nsi from branch to you locally https://github.com/APshenkin/wails/blob/feature/open-files/v2/pkg/buildassets/build/windows/installer/project.nsi I think we need input from @leaanthony regarding upgrading project.nsi on new build. I assume it's not doing so to avoid cases when user did some custom changes there |
Just catching up. Is the issue that the NSIS config in the PR isn't being picked up when using |
I will try to take a look into the PR this weekend. |
Yeah, that's intended behaviour and is in line with other artifacts that only get generated once. The idea is that project.nsi can be customized and is never overwritten if it's there. Whereas the One can simply delete it and it gets regenerated during the next |
I did a new init this time and interestingly the reg files generated weirdly but opposite again. I also have both !macro wails.unassociateFiles in wails_tools.nsh and !insertmacro wails.unassociateFiles in project.nsi and the reg keys remain after being uninstalled. @APshenkin Sorry to be a bother, can you provide exact commands starting from a new init template I can run to test the same senario as your working example to see if something I'm doing differently has caused my issues? |
@APshenkin any updates? Looking to get this in 👍 Thank you 🙏 |
@PylotLight I think the registry keys that you searching is not something that is inserted by our nsis script. E.g. if you have such configuration
This is what will be installed in registry Then I assume, when you open file in explorer it will be registered in But there is nothing that installation should do. It will be automatically picked by Windows.
Well, you are looking to other reg keys, that we are not installing. It's something that Windows set by themselves. BTW it's not a problem, that the records are still there, as if you uninstall app, it will not be able to open app and will show "Open With" dialog BTW here is step by step guide that works to me for from scratch project:
then in some other place
then modify wails.json to
run BTW, The same nsis script is used in Tauri and Electron. @leaanthony I don't have anything to do here more. It's just works :) |
Alrighty can confirm that worked quite well. Only issue im currently seeing its when trying to do multiple registrations, it seems it randomly has issues with some extensions. Due to the fact that this mostly seems to work with multiple other extensions that I've tested, I would call this good to go as far as my opinion goes, especially given we're not about to unit test every single possible windows extension as to what's not working for me on that one. (Could honestly be a special windows problem or my machine specifically, although I did try multiple rebuilds and reinstalls and that same extension continued to have issues)
|
We can always bugfix if needed. Thanks for this @APshenkin - really appreciate it. |
Description
Implements file association for macOS/Windows #1830
Users can specify list of associated file types in
wails.json
config with following paramsAlso custom icons for files are supported 🚀
For Linux will try to investigate what can be done later
Few comments regarding implementation
MacOS: Darwin handle opening file by raising
openFile
event. Callback is added for app configuration to handle this correctly.Windows: On Windows fileAssociation is done via NSIS installer. So apps should be distributed with it to have this feature.
When associated file is opened, Windows launches new instance of the app and pass filePath as argument. So apps developers should parse args and handle situation properly. However it's common practic to frameworks like Electron or Tauri provide capabilities to lock single instance and handle cases, when new instance is opened. Seems wails v3 will have support of it #1351 . But currently this plugin not supporting passing arguments from new instance for first one https://github.com/wailsapp/wails/blob/v3-alpha/v3/plugins/single_instance/plugin_windows.go
Linux: To setup association and icons changes in client system should be done. As wails doesn't support bundling for linux now, nothing was added in this PR for it, but in test repo that is provided below you can see how this can be done using nfmp
You can see how it works here.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Test repo is available here https://github.com/APshenkin/wails-open-file
PR should be fetched and replace in go.mod should be adjusted
Test Configuration
Checklist:
website/src/pages/changelog.mdx
with details of this PR