setting up mime for Firefox after compiling Principia on Linux

freelikegnu
Posted on 2024-01-21 19:14 (edited 2024-01-21 19:14) Link

I compiled and ran Principia just fine (actually its awesome!) but Firefox does not do anything with principia:// urls. (I thought it would at least ask what to do) I've looked up some mime type information and found some clues in the packaging/ folder but something is not clicking with me to understand. Please advise. Thank you!

(Avatar)
ROllerozxa
Posted on 2024-01-21 19:24 (edited 2024-01-21 19:24) Link

Yes, so principia-url-handler.desktop in the packaging/ folder is for handling the principia:// protocol URLs. This gets installed when you do ninja install or package the game, but if you're running from source then it won't know where to look.

The method I've recommended doing on the Wiki for getting it to work with a source tree build is modifying the Exec path and putting it in ~/.local/share/applications/. Maybe the MIME database needs to be updated after you do this, can't exactly remember.

I'm unsure if there's any better way to solve this. Maybe the game should write this file automatically to the local applications folder if it's not been installed to the system, which is probably what I'll need to do for the AppImage version anyways.

freelikegnu
Posted on 2024-01-22 00:57 (edited 2024-01-22 01:26) Link

Thanks for the suggestions: I edited and added principia.desktop and principia-url-handler.desktop to ~/.local/share/applications

I can now run Principia from the Xcfe menu, but Firefox refuses to do anything. Tried again after reboot with same results.

Also tried with Chrome and got a location not supported error: https://imgur.com/2gZt0RB.png

EDIT: OK I figured it out: I had to edit the handlers.json in the firefox profile folder and add

"principia":{"action":2,"handlers":[{"name":"principia","path":"/path_to_folder_with_executable/principia"}],

within the list of existing handlers. There must be a way that does not require editing the file directly but at least it works now.

(Avatar)
ROllerozxa
Posted on 2024-01-31 20:46 Link

While I was working on the AppImage builds I figured out what was missing in the documentation, namely calling xdg-mime. I assume this is what package managers do automatically when they call update-desktop-database, as when I e.g. build and install the AUR package it will work out of the box without having to register any association. I've updated the Wiki page to include these details.

I've also done some improvements to the level play buttons, if you press it three times a little box will pop up linking to a troubleshooting page on the Wiki which should contain all the possible issues I can think one would run into with the protocol links on various platforms. Hopefully it will be of use to anyone else who has issues with it in the future.