From 04bf9cad1627acd0c97fd1f236c479c16c8ce837 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Fri, 18 Apr 2025 14:09:34 +0200 Subject: [PATCH] change mime --- home/system/mime/default.nix | 131 +++++++++++++++++++++++------------ 1 file changed, 87 insertions(+), 44 deletions(-) diff --git a/home/system/mime/default.nix b/home/system/mime/default.nix index 29bf6c1..d400110 100644 --- a/home/system/mime/default.nix +++ b/home/system/mime/default.nix @@ -1,50 +1,93 @@ -# Mime allows us to configure the default applications for each file type -{ +{ pkgs, lib, ... }: +with lib; +let + defaultApps = { + browser = [ "zen-beta.desktop" ]; + text = [ "org.gnome.TextEditor.desktop" ]; + image = [ "imv-dir.desktop" ]; + audio = [ "mpv.desktop" ]; + video = [ "mpv.desktop" ]; + directory = [ "thunar.desktop" ]; + office = [ "libreoffice.desktop" ]; + pdf = [ "zathura.desktop" ]; + terminal = [ "kitty.desktop" ]; + discord = [ "discord.desktop" ]; + }; + + mimeMap = { + text = [ "text/plain" ]; + image = [ + "image/bmp" + "image/gif" + "image/jpeg" + "image/jpg" + "image/png" + "image/svg+xml" + "image/tiff" + "image/vnd.microsoft.icon" + "image/webp" + ]; + audio = [ + "audio/aac" + "audio/mpeg" + "audio/ogg" + "audio/opus" + "audio/wav" + "audio/webm" + "audio/x-matroska" + ]; + video = [ + "video/mp2t" + "video/mp4" + "video/mpeg" + "video/ogg" + "video/webm" + "video/x-flv" + "video/x-matroska" + "video/x-msvideo" + ]; + directory = [ "inode/directory" ]; + browser = [ + "text/html" + "x-scheme-handler/about" + "x-scheme-handler/http" + "x-scheme-handler/https" + "x-scheme-handler/unknown" + ]; + office = [ + "application/vnd.oasis.opendocument.text" + "application/vnd.oasis.opendocument.spreadsheet" + "application/vnd.oasis.opendocument.presentation" + "application/vnd.openxmlformats-officedocument.wordprocessingml.document" + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + "application/vnd.openxmlformats-officedocument.presentationml.presentation" + "application/msword" + "application/vnd.ms-excel" + "application/vnd.ms-powerpoint" + "application/rtf" + ]; + pdf = [ "application/pdf" ]; + terminal = [ "terminal" ]; + # archive = [ + # "application/zip" + # "application/rar" + # "application/7z" + # "application/*tar" + # ]; + discord = [ "x-scheme-handler/discord" ]; + }; + + associations = with lists; + listToAttrs (flatten (mapAttrsToList + (key: map (type: attrsets.nameValuePair type defaultApps."${key}")) + mimeMap)); +in { xdg = { - enable = true; - mime.enable = true; - userDirs.enable = true; - portal.xdgOpenUsePortal = true; - configFile."mimeapps.list".force = - true; # don't error when mimeapps.list is replaced, it gets replaced often + configFile."mimeapps.list".force = true; mimeApps = { enable = true; - defaultApplications = { - "text/markdown" = "nvim.desktop"; - "text/plain" = "nvim.desktop"; - "text/x-shellscript" = "nvim.desktop"; - "text/x-python" = "nvim.desktop"; - "text/x-go" = "nvim.desktop"; - "text/css" = "nvim.desktop"; - "text/javascript" = "nvim.desktop"; - "text/x-c" = "nvim.desktop"; - "text/x-c++" = "nvim.desktop"; - "text/x-java" = "nvim.desktop"; - "text/x-rust" = "nvim.desktop"; - "text/x-yaml" = "nvim.desktop"; - "text/x-toml" = "nvim.desktop"; - "text/x-dockerfile" = "nvim.desktop"; - "text/x-xml" = "nvim.desktop"; - "text/x-php" = "nvim.desktop"; - "image/jpeg" = "imv.desktop"; - "image/jpg" = "imv.desktop"; - "image/webp" = "imv.desktop"; - "inode/directory" = "thunar.desktop"; - "application/pdf" = "zathura.desktop"; - "image/png" = "imv-dir.desktop"; - - "image/gif" = "zen-beta.desktop"; - "x-scheme-handler/http" = "zen-beta.desktop"; - "x-scheme-handler/https" = "zen-beta.desktop"; - "x-scheme-handler/chrome" = "zen-beta.desktop"; - "text/html" = "zen-beta.desktop"; - "application/x-extension-htm" = "zen-beta.desktop"; - "application/x-extension-html" = "zen-beta.desktop"; - "application/x-extension-shtml" = "zen-beta.desktop"; - "application/xhtml+xml" = "zen-beta.desktop"; - "application/x-extension-xhtml" = "zen-beta.desktop"; - "application/x-extension-xht" = "zen-beta.desktop"; - }; + associations.added = associations; + defaultApplications = associations; }; }; }