Skip to content

Commit

Permalink
Modularize xdg config
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRTitor committed Mar 18, 2024
1 parent 0fab637 commit 1a3f242
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 52 deletions.
57 changes: 57 additions & 0 deletions home-manager/xdg.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This config file is used to configure the XDG user directories and MIME types
# which is responsible for opening specific files, links in specific apps
# Imported in home manager ../home.nix

{ config, ... }:
{
xdg.enable = true;
xdg.userDirs = {
enable = true;
createDirectories = true;
music = "${config.home.homeDirectory}/Media/Music";
videos = "${config.home.homeDirectory}/Media/Videos";
pictures = "${config.home.homeDirectory}/Media/Pictures";
templates = "${config.home.homeDirectory}/Templates";
download = "${config.home.homeDirectory}/Downloads";
documents = "${config.home.homeDirectory}/Documents";
desktop = "${config.home.homeDirectory}/Desktop"; # null; # hyprland does not use desktop
publicShare = "${config.home.homeDirectory}/Public"; # null;

extraConfig = {
# XDG_DOTFILES_DIR = "${config.home.homeDirectory}/.dotfiles";
XDG_ARCHIVE_DIR = "${config.home.homeDirectory}/Archive";
# XDG_VM_DIR = "${config.home.homeDirectory}/Machines";
# XDG_ORG_DIR = "${config.home.homeDirectory}/Org";
XDG_PODCAST_DIR = "${config.home.homeDirectory}/Media/Podcasts";
XDG_BOOK_DIR = "${config.home.homeDirectory}/Media/Books";
};
};
xdg.mime.enable = true;
xdg.mimeApps.enable = true;
xdg.mimeApps.defaultApplications = {
"text/html" = "google-chrome.desktop";
"x-scheme-handler/http" = "google-chrome.desktop";
"x-scheme-handler/https" = "google-chrome.desktop";
"x-scheme-handler/about" = "google-chrome.desktop";
"x-scheme-handler/unknown" = "google-chrome.desktop";
"x-scheme-handler/tg" = "userapp-Telegram Desktop-TLQ2K2.desktop";
};
xdg.mimeApps.associations.added = {
# Text files
"text/plain" = "org.xfce.mousepad.desktop;";
"application/x-shellscript" = "org.xfce.mousepad.desktop;";
"application/json" = "org.xfce.mousepad.desktop;code.desktop;";
"application/xml" = "org.xfce.mousepad.desktop;";
"inode/directory" = "code.desktop;";
# Telegram
"x-scheme-handler/tg" = "org.telegram.desktop.desktop;userapp-Telegram Desktop-TLQ2K2.desktop;";
"x-xdg-protocol-tg" = "org.telegram.desktop.desktop;userapp-Telegram Desktop-TLQ2K2.desktop;";

# Images
"image/png" = "org.gnome.eog.desktop;";
"image/jpeg" = "org.gnome.eog.desktop;";

# PDF
"application/pdf" = "google-chrome.desktop;";
};
}
53 changes: 1 addition & 52 deletions home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# system packages are imported in ./configuration.nix
./packages/user-packages.nix # user specific packages
./home-manager/shell.nix # shell (bash, zsh) config
./home-manager/xdg.nix # xdg config
./home-manager/git.nix # git config
./home-manager/starship/starship.nix # starship config
./home-manager/alacritty/alacritty.nix
Expand All @@ -24,58 +25,6 @@
./home-manager/virt-manager/virt-manager.nix
];

xdg.enable = true;
xdg.userDirs = {
enable = true;
createDirectories = true;
music = "${config.home.homeDirectory}/Media/Music";
videos = "${config.home.homeDirectory}/Media/Videos";
pictures = "${config.home.homeDirectory}/Media/Pictures";
templates = "${config.home.homeDirectory}/Templates";
download = "${config.home.homeDirectory}/Downloads";
documents = "${config.home.homeDirectory}/Documents";
desktop = "${config.home.homeDirectory}/Desktop"; # null; # hyprland does not use desktop
publicShare = "${config.home.homeDirectory}/Public"; # null;

extraConfig = {
# XDG_DOTFILES_DIR = "${config.home.homeDirectory}/.dotfiles";
XDG_ARCHIVE_DIR = "${config.home.homeDirectory}/Archive";
# XDG_VM_DIR = "${config.home.homeDirectory}/Machines";
# XDG_ORG_DIR = "${config.home.homeDirectory}/Org";
XDG_PODCAST_DIR = "${config.home.homeDirectory}/Media/Podcasts";
XDG_BOOK_DIR = "${config.home.homeDirectory}/Media/Books";
};
};
xdg.mime.enable = true;
xdg.mimeApps.enable = true;
xdg.mimeApps.defaultApplications = {
"text/html" = "google-chrome.desktop";
"x-scheme-handler/http" = "google-chrome.desktop";
"x-scheme-handler/https" = "google-chrome.desktop";
"x-scheme-handler/about" = "google-chrome.desktop";
"x-scheme-handler/unknown" = "google-chrome.desktop";
"x-scheme-handler/tg" = "userapp-Telegram Desktop-TLQ2K2.desktop";
};
xdg.mimeApps.associations.added = {
# Text files
"text/plain" = "org.xfce.mousepad.desktop;";
"application/x-shellscript" = "org.xfce.mousepad.desktop;";
"application/json" = "org.xfce.mousepad.desktop;code.desktop;";
"application/xml" = "org.xfce.mousepad.desktop;";
"inode/directory" = "code.desktop;";
# Telegram
"x-scheme-handler/tg" = "org.telegram.desktop.desktop;userapp-Telegram Desktop-TLQ2K2.desktop;";
"x-xdg-protocol-tg" = "org.telegram.desktop.desktop;userapp-Telegram Desktop-TLQ2K2.desktop;";

# Images
"image/png" = "org.gnome.eog.desktop;";
"image/jpeg" = "org.gnome.eog.desktop;";

# PDF
"application/pdf" = "google-chrome.desktop;";
};


# link the configuration file in current directory to the specified location in home directory
# home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg;

Expand Down

0 comments on commit 1a3f242

Please sign in to comment.