chaiNNer icon indicating copy to clipboard operation
chaiNNer copied to clipboard

Associate .CHN files with chainNNer executable

Open Athari opened this issue 3 years ago • 4 comments
trafficstars

File extensions should be associated with the applications which support them. This allows:

  1. Double-clicking a file to open the application with the file loaded;
  2. Using the global recently opened file list to open the application;
  3. Right-clicking a pinned application icon in the Start Menu or on the Task Bar and choosing a recently opened file;
  4. Setting an icon for the associated file type;
  5. 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.

Athari avatar Oct 07 '22 12:10 Athari

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

joeyballentine avatar Oct 07 '22 13:10 joeyballentine

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.

joeyballentine avatar Oct 12 '22 03:10 joeyballentine

I found this and this. Seems like electron build has an fileAssociations config. Maybe we can use that.

RunDevelopment avatar Oct 12 '22 12:10 RunDevelopment

We don't use electron builder, we use electron forge

joeyballentine avatar Oct 12 '22 12:10 joeyballentine

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 avatar Nov 21 '22 23:11 joeyballentine

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

Athari avatar Nov 22 '22 01:11 Athari

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.

joeyballentine avatar Nov 22 '22 02:11 joeyballentine