From 62265a466cb564cbb519456255679f013845daf5 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sat, 15 Jun 2024 14:18:36 +0200 Subject: [PATCH] Manage default applications with home-manager --- home.nix | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/home.nix b/home.nix index 59942f3..09c612c 100644 --- a/home.nix +++ b/home.nix @@ -7,7 +7,81 @@ ]; xsession.enable = true; - xdg.userDirs.enable = true; + + xdg = { + userDirs.enable = true; + + mimeApps = { + enable = true; + + defaultApplications = + let + applications = { + telegram = { + mimeApp = "org.telegram.desktop.desktop"; + mimeTypes = [ "x-scheme-handler/tg" ]; + }; + + librewolf = { + mimeApp = "librewolf.desktop"; + + mimeTypes = [ + "x-scheme-handler/http" + "text/html" + "application/xhtml+xml" + "x-scheme-handler/https" + "application/pdf" + ]; + }; + + gnomeTextEditor = { + mimeApp = "org.gnome.TextEditor.desktop"; + mimeTypes = [ "text/plain" ]; + }; + + thunderbird = { + mimeApp = "thunderbird.desktop"; + mimeTypes = [ "x-scheme-handler/mailto" ]; + }; + + loupe = { + mimeApp = "org.gnome.Loupe.desktop"; + mimeTypes = [ + "image/jpeg" + "image/png" + "image/gif" + "image/webp" + "image/tiff" + "image/x-tga" + "image/vnd-ms.dds" + "image/x-dds" + "image/bmp" + "image/vnd.microsoft.icon" + "image/vnd.radiance" + "image/x-exr" + "image/x-portable-bitmap" + "image/x-portable-graymap" + "image/x-portable-pixmap" + "image/x-portable-anymap" + "image/x-qoi" + "image/svg+xml" + "image/svg+xml-compressed" + "image/avif" + "image/heic" + "image/jxl" + ]; + }; + }; + + mimeTypesForApp = { mimeApp, mimeTypes }: map + ( + mimeType: { "${mimeType}" = mimeApp; } + ) + mimeTypes; + in + lib.zipAttrs (lib.flatten (map mimeTypesForApp (builtins.attrValues applications))); + }; + }; home = { username = "pim";