chaiNNer
chaiNNer copied to clipboard
Associate .CHN files with chainNNer executable
File extensions should be associated with the applications which support them. This allows:
- Double-clicking a file to open the application with the file loaded;
- Using the global recently opened file list to open the application;
- Right-clicking a pinned application icon in the Start Menu or on the Task Bar and choosing a recently opened file;
- Setting an icon for the associated file type;
- Other optional features like creating a new file from Explorer, tooltips etc.
This only requires changes to the Registry during installation and opening a file from the command line. See https://learn.microsoft.com/en-us/windows/win32/shell/fa-sample-scenarios (Windows 7+ adds tons of black magic for managing associations, especially default applications, but the good old method just works.)
The same thing with Linux. I believe this involves adding a custom MIME type like application/vnd.chainner.chain+json and associating it with the app using a .desktop file.
The only reason I never did this is because I'm pretty sure I can't run anything custom during the installation process. I could however add something in settings or something where you could click a button and have it make the associations
Did a little bit of research on this. Basically, for windows, we'll need to check to see if chaiNNer was started with the --squirrel-install arg. That will let us know that it's running on install. Then, we can use something like this package to manually edit the registry to create the association. Not sure about linux or macos though.
I found this and this. Seems like electron build has an fileAssociations config. Maybe we can use that.
We don't use electron builder, we use electron forge
Btw, I looked into this some more the other day. Turns out it's pretty impossible to do easily, especially since Microsoft made it even harder to do programmatically. It would be nice if we used electron-builder since that has the built-in fileAssociations thing, but we don't. So, I'm not sure this is possible for us, at least not now.
@joeyballentine What do you mean by "Microsoft made it even harder to do programmatically"? I'm pretty sure it still requires only several writes to the Registry. And judging by my experience as a user, when Windows detects "the old way" of registering an association, it just silently transforms it into "the new way", so even if you overwrite everything and ignore all protections, it'll still work fine.
What do you mean by "Microsoft made it even harder to do programmatically"?
There was a utility built into command prompt for registering file extensions to programs, but they made that not work anymore.
As for editing the registry, there seems to not be a NodeJS windows registry editor package that doesn't require some sort of compilation process.
Would you care to elaborate on exactly how you would accomplish this? Because i was unable to figure out a way.