diff --git a/home/programs/default.nix b/home/programs/default.nix index d700d58..2f7b29c 100644 --- a/home/programs/default.nix +++ b/home/programs/default.nix @@ -2,5 +2,6 @@ _: { imports = [ ./graphical ./terminal + ./xdg ]; } diff --git a/home/programs/xdg/default.nix b/home/programs/xdg/default.nix new file mode 100644 index 0000000..2219625 --- /dev/null +++ b/home/programs/xdg/default.nix @@ -0,0 +1,14 @@ +{config, ...}: { + imports = [ + ./mime-apps.nix + ./user-dirs.nix + ]; + + xdg = { + enable = true; + cacheHome = "${config.home.homeDirectory}/.cache"; + configHome = "${config.home.homeDirectory}/.config"; + dataHome = "${config.home.homeDirectory}/.local/share"; + stateHome = "${config.home.homeDirectory}/.local/state"; + }; +} diff --git a/home/programs/xdg/mime-apps.nix b/home/programs/xdg/mime-apps.nix new file mode 100644 index 0000000..984e59e --- /dev/null +++ b/home/programs/xdg/mime-apps.nix @@ -0,0 +1,42 @@ +# Manage $XDG_CONFIG_HOME/mimeapps.list +{ + xdg.mimeApps = { + enable = true; + associations.added = let + browser = "firefox.desktop"; + textEditor = browser; # nvim doesn't work properly with xdg-open, just use the browser + fileManager = "pcmanfm-qt.desktop"; + archiveManager = "org.gnome.FileRoller.desktop"; + imageViewer = "org.nomacs.ImageLounge.desktop"; + videoPlayer = "mpv.desktop"; + audioPlayer = "mpv.desktop"; + in { + "text/html" = [browser]; + "x-scheme-handler/http" = [browser]; + "x-scheme-handler/https" = [browser]; + "x-scheme-handler/about" = [browser]; + "x-scheme-handler/unknown" = [browser]; + "application/x-extension-htm" = [browser]; + "application/x-extension-html" = [browser]; + "application/x-extension-shtml" = [browser]; + "application/xhtml+xml" = [browser]; + "application/x-extension-xhtml" = [browser]; + "application/x-extension-xht" = [browser]; + + "inode/directory" = [fileManager]; + "application/zip" = [archiveManager]; + "application/x-xz-compressed-tar" = [archiveManager]; + + "image/*" = [imageViewer]; + "audio/*" = [audioPlayer]; + "video/*" = [videoPlayer]; + + "text/plain" = [textEditor]; + "application/json" = [textEditor]; + + "x-scheme-handler/spotify" = ["spotify.desktop"]; + "x-scheme-handler/tg" = ["telegramdesktop.desktop"]; + "x-scheme-handler/msteams" = ["teams.desktop"]; # I need it for school, don't judge me + }; + }; +} diff --git a/home/programs/xdg/user-dirs.nix b/home/programs/xdg/user-dirs.nix new file mode 100644 index 0000000..e7af269 --- /dev/null +++ b/home/programs/xdg/user-dirs.nix @@ -0,0 +1,22 @@ +# Manage $XDG_CONFIG_HOME/user-dirs.dirs +{ config, ... }: { + xdg.userDirs = { + enable = true; + createDirectories = true; + + desktop = null; + documents = null; + download = "${config.home.homeDirectory}/Downloads"; + + publicShare = "${config.home.homeDirectory}/.local/share/public"; + templates = "${config.home.homeDirectory}/.local/share/templates"; + + music = "${config.home.homeDirectory}/Media/Music"; + pictures = "${config.home.homeDirectory}/Media/Pictures"; + videos = "${config.home.homeDirectory}/Media/Videos"; + + extraConfig = { + XDG_SCREENSHOTS_DIR = "${config.xdg.userDirs.pictures}/Screenshots"; + }; + }; +}