From b341f7f4fcd4393249a5902660565ed68d956136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Jane=C5=BEi=C4=8D?= Date: Tue, 14 Apr 2026 23:52:02 +0200 Subject: [PATCH] feat: setup mime apps --- features/desktop.nix | 118 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 110 insertions(+), 8 deletions(-) diff --git a/features/desktop.nix b/features/desktop.nix index 4e1a3df..7d8e97f 100644 --- a/features/desktop.nix +++ b/features/desktop.nix @@ -65,7 +65,6 @@ xdg.portal = { enable = true; - xdgOpenUsePortal = true; extraPortals = with pkgs; [ xdg-desktop-portal-wlr xdg-desktop-portal-gtk @@ -127,12 +126,13 @@ wl-mirror protonmail-bridge ledger-live-desktop + imv + yazi + nemo + file-roller + libreoffice-still ]; - xdg.mime.defaultApplications = { - "application/pdf" = "org.pwmt.zathura.desktop"; - }; - # kindle udev rules for calibre features.udev.kindle.enable = lib.mkDefault true; }) @@ -158,8 +158,110 @@ cfg = osConfig.features.desktop; in { - config = lib.mkIf cfg.enable { - home.file.".assets".source = inputs.assets; - }; + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + { + home.file.".assets".source = inputs.assets; + } + + (lib.mkIf cfg.apps.enable { + # TODO:(@janezicmatej) consider moving nvim desktop entry to neovim feature + xdg.desktopEntries.nvim = { + name = "Neovim"; + exec = "ghostty -e nvim %F"; + terminal = false; + mimeType = [ + "text/plain" + "application/json" + "text/markdown" + ]; + }; + + xdg.mimeApps = { + enable = true; + defaultApplications = { + # text + "text/plain" = "nvim.desktop"; + "application/json" = "nvim.desktop"; + "text/markdown" = "nvim.desktop"; + + # web + "text/html" = "google-chrome.desktop"; + "application/xhtml+xml" = "google-chrome.desktop"; + "x-scheme-handler/http" = "google-chrome.desktop"; + "x-scheme-handler/https" = "google-chrome.desktop"; + "x-scheme-handler/ftp" = "google-chrome.desktop"; + "x-scheme-handler/about" = "google-chrome.desktop"; + "x-scheme-handler/unknown" = "google-chrome.desktop"; + + # mail and calendar + "x-scheme-handler/mailto" = "thunderbird.desktop"; + "message/rfc822" = "thunderbird.desktop"; + "text/calendar" = "thunderbird.desktop"; + + # documents + "application/pdf" = "org.pwmt.zathura.desktop"; + "application/postscript" = "org.pwmt.zathura.desktop"; + "image/vnd.djvu" = "org.pwmt.zathura.desktop"; + "application/epub+zip" = "org.pwmt.zathura.desktop"; + + # office + "application/msword" = "libreoffice-writer.desktop"; + "application/vnd.ms-excel" = "libreoffice-calc.desktop"; + "application/vnd.ms-powerpoint" = "libreoffice-impress.desktop"; + "application/vnd.openxmlformats-officedocument.wordprocessingml.document" = + "libreoffice-writer.desktop"; + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" = "libreoffice-calc.desktop"; + "application/vnd.openxmlformats-officedocument.presentationml.presentation" = + "libreoffice-impress.desktop"; + "application/vnd.oasis.opendocument.text" = "libreoffice-writer.desktop"; + "application/vnd.oasis.opendocument.spreadsheet" = "libreoffice-calc.desktop"; + "application/vnd.oasis.opendocument.presentation" = "libreoffice-impress.desktop"; + "text/csv" = "libreoffice-calc.desktop"; + + # images + "image/png" = "imv-dir.desktop"; + "image/jpeg" = "imv-dir.desktop"; + "image/gif" = "imv-dir.desktop"; + "image/webp" = "imv-dir.desktop"; + "image/tiff" = "imv-dir.desktop"; + "image/bmp" = "imv-dir.desktop"; + "image/svg+xml" = "google-chrome.desktop"; + + # video + "video/mp4" = "mpv.desktop"; + "video/x-matroska" = "mpv.desktop"; + "video/webm" = "mpv.desktop"; + "video/quicktime" = "mpv.desktop"; + "video/x-msvideo" = "mpv.desktop"; + + # audio + "audio/mpeg" = "mpv.desktop"; + "audio/flac" = "mpv.desktop"; + "audio/ogg" = "mpv.desktop"; + "audio/wav" = "mpv.desktop"; + "audio/aac" = "mpv.desktop"; + + # archives + "application/zip" = "org.gnome.FileRoller.desktop"; + "application/x-tar" = "org.gnome.FileRoller.desktop"; + "application/gzip" = "org.gnome.FileRoller.desktop"; + "application/x-rar-compressed" = "org.gnome.FileRoller.desktop"; + "application/x-7z-compressed" = "org.gnome.FileRoller.desktop"; + "application/x-bzip2" = "org.gnome.FileRoller.desktop"; + "application/x-xz" = "org.gnome.FileRoller.desktop"; + + # file manager + "inode/directory" = "nemo.desktop"; + + # app deep links + "x-scheme-handler/tg" = "org.telegram.desktop.desktop"; + "x-scheme-handler/discord" = "vesktop.desktop"; + "x-scheme-handler/slack" = "slack.desktop"; + }; + }; + }) + ] + ); }; }