I’m making a new post go get more attention.
I am trying to make a module that lalows specifying default application launchers. The format would be something like this-
programs.defaults.defaults = {
"application/pdf" = [ pkgs.zathura "${pkgs.evince}/share/applications/org.gnome.Evince.desktop" ];
"inode/directory" = [ "${pkgs.spaceFM}/share/applications/spacefm.desktop" pkgs.ranger pkgs.vifm ];
"video/mp4" = pkgs.vlc;
} ;
PR
The PR is here: [WIP] nixos/open-with: init by SRGOM · Pull Request #88025 · NixOS/nixpkgs · GitHub
Why
There is some previous discussion on the need for this here- Configure how xdg-open opens html files? and also on the PR but to summarize, the problem is that there is no straightforward way to override the global defaults from user code. Most programs read their own choice of user space files and the management of those files isn’t so easy either. That said, most programs also do respect the global defaults.
The global defaults themselves are set in what seems like alphabetical order so for my computer (and for yours) inkscape opens pdf, not org.gnome.Evince
, code
(visual studio code written in electron) opens directory, not vifm. The list can ovviously go on.
This code should allow root to specify sane default launchers.
help needed
I wrote the code assume environment.extraSetup
would let me manipulate a mimeinfo.cache
. However, when my module tries to read that file, it doesn’t find any file. I’m going to spend some more time on this this weekend but I am wondering if any experts here can (hopefully without spending time) tell me a way to proceed, basically ensuring in some way that my module runs after whichver module generates mimeinfo.cache
or tell me which module does it.
EDIT: I think I found the module: nixos/modules/config/xdg/mime.nix
I will see how to go from here.