Set default application for mime type with home-manager

xdg-open foo.pdf opens the pdf in LibreOffice Draw, but I want it to open in evince. I tried this but it didn’t change anything:

  home.xdg.mimeApps = {
    enable = true;
    defaultApplications = {
      "application/pdf" = ["evince.desktop"];
    };
  };
1 Like

Two shots in the dark.

  1. Maybe there are some other xdg config files sitting in your home dir was generated by some other prog and its superseding the one generated by hm.

  2. Did you try setting home.xdg.enable = true;?

1 Like

Useful debugging tools:

XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query filetype foo.pdf

XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default application/pdf

fd evince.desktop /

This works:

  xdg.mimeApps = {
    enable = true;
    associations.added = {
      "application/pdf" = ["org.gnome.Evince.desktop"];
    };
    defaultApplications = {
      "application/pdf" = ["org.gnome.Evince.desktop"];
    };
  };
4 Likes