# Команды для терминала
# Узнать тип файла - xdg-mime query filetype foo.pdf
# Узнать нынешнее дефолт приложения - xdg-mime query default application/pdf
# Узнать имя приложения. Для примера взять evince - fd evince.desktop /
# Выведет пути, по которым можно понять как называется приложение
# В список [] можно через пробел добавить другие варианты. Если первая прога не откроет, то попытается вторая
# Список mime types смотрел тут https://mimetype.io/all-types
# Нагуглить значение "x-scheme-handler" невозможно. Как я понял, это кастом типы

##############################################################################
# Как система готова, то замени имена прог на реальные. Сейчас на абум стоят #
##############################################################################

{
  xdg.mimeApps = { # Конфиг для `~/.config/mimeapps.list`
    enable = true;
    defaultApplications = { # Стандартные приложения для открытия нужного файла
      # Browser
      "application/x-extension-htm"     = [ "librewolf.desktop" ];
      "application/x-extension-html"    = [ "librewolf.desktop" ];
      "application/x-extension-shtml"   = [ "librewolf.desktop" ];
      "application/x-extension-xht"     = [ "librewolf.desktop" ];
      "application/x-extension-xhtml"   = [ "librewolf.desktop" ];
      "application/xhtml+xml"           = [ "librewolf.desktop" ];
      "x-scheme-handler/about"          = [ "librewolf.desktop" ];
      "x-scheme-handler/chrome"         = [ "librewolf.desktop" ];
      "x-scheme-handler/http"           = [ "librewolf.desktop" ];
      "x-scheme-handler/https"          = [ "librewolf.desktop" ];
      "x-scheme-handler/unknown"        = [ "librewolf.desktop" ];
      # Images
      "image/*"                         = [ "qview.desktop" "imv.desktop" ];
      "image/avif"                      = [ "qview.desktop" "imv.desktop" ];
      "image/gif"                       = [ "qview.desktop" "imv.desktop" ];
      "image/jpeg"                      = [ "qview.desktop" "imv.desktop" ]; # Обычный jpeg, прогрузка сверху вниз
      "image/pjpeg"                     = [ "qview.desktop" "imv.desktop" ]; # Сначала размытый и постепенной лучше видно, для медленного инета
      "image/apng"                      = [ "qview.desktop" "imv.desktop" ]; # Анимированный png
      "image/png"                       = [ "qview.desktop" "imv.desktop" ];
      "image/svg+xml"                   = [ "qview.desktop" "imv.desktop" ];
      "image/webp"                      = [ "qview.desktop" "imv.desktop" ];
      "image/x-icon"                    = [ "qview.desktop" "imv.desktop" ];
      "image/vnd.microsoft.icon"        = [ "qview.desktop" "imv.desktop" ];
      # Video
      "video/*"                         = [ "mpv.desktop" ];
      "video/mp4"                       = [ "mpv.desktop" ];
      "video/mpeg"                      = [ "mpv.desktop" ];
      "video/quicktime"                 = [ "mpv.desktop" ];
      "video/webm"                      = [ "mpv.desktop" ];
      "video/x-matroska"                = [ "mpv.desktop" ];
      # Audio
      "audio/*"                         = [ "mpv.desktop" ];
      "audio/aac"                       = [ "mpv.desktop" ];
      "audio/flac"                      = [ "mpv.desktop" ];
      "audio/mp4"                       = [ "mpv.desktop" ];
      "audio/mpeg"                      = [ "mpv.desktop" ];
      "audio/ogg"                       = [ "mpv.desktop" ];
      "audio/opus"                      = [ "mpv.desktop" ];
      "audio/vnd.wav"                   = [ "mpv.desktop" ];
      "audio/webm"                      = [ "mpv.desktop" ];
      "audio/x-matroska"                = [ "mpv.desktop" ];
      "audio/x-mpegurl"                 = [ "mpv.desktop" ]; # Для .m3u. Это файл-плейлист
      "audio/x-opus+ogg"                = [ "mpv.desktop" ]; # What's this? Why not "audio/ogg" and "audio/opus"?
      # Text
      "text/*"                          = [ "nvim.desktop" "codium.desktop" ]; # Надо ли заменять nvim и всё что ниже на NixVim?
      "text/css"                        = [ "nvim.desktop" "codium.desktop" ];
      "text/csv"                        = [ "nvim.desktop" "codium.desktop" ];
      "text/html"                       = [ "nvim.desktop" "codium.desktop" "librewolf.desktop" "firefox.desktop" "chromium.desktop" ];
      "text/javascript"                 = [ "nvim.desktop" "codium.desktop" ];
      "text/markdown"                   = [ "nvim.desktop" "codium.desktop" ];
      "text/plain"                      = [ "nvim.desktop" "codium.desktop" ];
      "text/x-asm"                      = [ "nvim.desktop" "codium.desktop" ];
      "text/x-c"                        = [ "nvim.desktop" "codium.desktop" ];
      "text/x-python"                   = [ "nvim.desktop" "codium.desktop" ];
      "application/json"                = [ "nvim.desktop" "codium.desktop" "librewolf.desktop" "firefox.desktop" "chromium.desktop" ];
      "application/x-sh"                = [ "nvim.desktop" "codium.desktop" ];
      "application/x-shellscript"       = [ "nvim.desktop" "codium.desktop" ];
      "application/xml"                 = [ "nvim.desktop" "codium.desktop" ];
      "application/yaml"                = [ "nvim.desktop" "codium.desktop" ];
      # Мб потом добавить для docs варианты и разные виды архивов и ebook
      # Other
      "application/pdf"                 = [ "org.gnome.Evince.desktop" ];
      "application/x-zerosize"          = [ "nvim.desktop" "codium.desktop" ]; # Файл нулевого размера
      "application/zip"                 = [ "ark.desktop" ];
      "application/x-bittorrent"        = [ "qbittorrent.desktop" ];
      "x-scheme-handler/magnet"         = [ "qbittorrent.desktop" ];
      "inode/directory"                 = [ "dolphin.desktop" ];
      "x-scheme-handler/mailto"         = [ "thunderbird.desktop" ];
      "x-scheme-handler/jetbrains"      = [ "jetbrains-toolbox.desktop" ];
    };

    associations.added = { # Дополнительные приложения для нужного файла. Будет в меню "Открыть с помощью"
      # Images
      "image/*"                         = [ "qview.desktop" "imv.desktop" ];
      "image/avif"                      = [ "qview.desktop" "imv.desktop" ];
      "image/gif"                       = [ "qview.desktop" "imv.desktop" ];
      "image/jpeg"                      = [ "qview.desktop" "imv.desktop" ]; # Обычный jpeg, прогрузка сверху вниз
      "image/pjpeg"                     = [ "qview.desktop" "imv.desktop" ]; # Сначала размытый и постепенной лучше видно, для медленного инета
      "image/apng"                      = [ "qview.desktop" "imv.desktop" ]; # Анимированный png
      "image/png"                       = [ "qview.desktop" "imv.desktop" ];
      "image/svg+xml"                   = [ "qview.desktop" "imv.desktop" ];
      "image/webp"                      = [ "qview.desktop" "imv.desktop" ];
      "image/x-icon"                    = [ "qview.desktop" "imv.desktop" ];
      "image/vnd.microsoft.icon"        = [ "qview.desktop" "imv.desktop" ];
      # Text
      "text/*"                          = [ "nvim.desktop" "codium.desktop" ]; # Надо ли заменять nvim и всё что ниже на NixVim?
      "text/css"                        = [ "nvim.desktop" "codium.desktop" ];
      "text/csv"                        = [ "nvim.desktop" "codium.desktop" ];
      "text/html"                       = [ "nvim.desktop" "codium.desktop" "librewolf.desktop" "firefox.desktop" "chromium.desktop" ];
      "text/javascript"                 = [ "nvim.desktop" "codium.desktop" ];
      "text/markdown"                   = [ "nvim.desktop" "codium.desktop" ];
      "text/plain"                      = [ "nvim.desktop" "codium.desktop" ];
      "text/x-asm"                      = [ "nvim.desktop" "codium.desktop" ];
      "text/x-c"                        = [ "nvim.desktop" "codium.desktop" ];
      "text/x-python"                   = [ "nvim.desktop" "codium.desktop" ];
      "application/json"                = [ "nvim.desktop" "codium.desktop" "librewolf.desktop" "firefox.desktop" "chromium.desktop" ];
      "application/x-sh"                = [ "nvim.desktop" "codium.desktop" ];
      "application/x-shellscript"       = [ "nvim.desktop" "codium.desktop" ];
      "application/xml"                 = [ "nvim.desktop" "codium.desktop" ];
      "application/yaml"                = [ "nvim.desktop" "codium.desktop" ];
    };
  };
}