home/defaultApps: cleanup & reorg

This commit is contained in:
Aly Raffauf 2024-06-29 22:02:23 -04:00
parent c3776d318a
commit 3d220582e9

View file

@ -1,22 +1,10 @@
{ {
pkgs,
lib,
config, config,
lib,
pkgs,
... ...
}: { }: {
config = lib.mkIf config.ar.home.defaultApps.enable { config = lib.mkIf config.ar.home.defaultApps.enable {
home.packages = with config.ar.home.defaultApps; [
audioPlayer
editor
fileManager
imageViewer
pdfViewer
terminal
terminalEditor
videoPlayer
webBrowser
];
dconf = { dconf = {
enable = true; enable = true;
settings = { settings = {
@ -25,72 +13,90 @@
}; };
}; };
xdg.desktopEntries = let home = {
mkDefaultEntry = name: package: { packages = with config.ar.home.defaultApps; [
name = "Default ${name}"; audioPlayer
exec = "${lib.getExe package} %U"; editor
terminal = false; fileManager
settings = { imageViewer
NoDisplay = "true"; pdfViewer
}; terminal
terminalEditor
videoPlayer
webBrowser
];
sessionVariables = {
BROWSER = "${lib.getExe config.ar.home.defaultApps.webBrowser}";
EDITOR = "${lib.getExe config.ar.home.defaultApps.terminalEditor}";
TERMINAL = "${lib.getExe config.ar.home.defaultApps.terminal}";
}; };
in {
defaultAudioPlayer = mkDefaultEntry "Audio Player" config.ar.home.defaultApps.audioPlayer;
defaultEditor = mkDefaultEntry "Editor" config.ar.home.defaultApps.editor;
defaultFileManager = mkDefaultEntry "File Manager" config.ar.home.defaultApps.fileManager;
defaultImageViewer = mkDefaultEntry "Image Viewer" config.ar.home.defaultApps.imageViewer;
defaultPdfViewer = mkDefaultEntry "PDF Viewer" config.ar.home.defaultApps.pdfViewer;
defaultVideoPlayer = mkDefaultEntry "Video Player" config.ar.home.defaultApps.videoPlayer;
defaultWebBrowser = mkDefaultEntry "Web Browser" config.ar.home.defaultApps.webBrowser;
}; };
xdg.mimeApps = { xdg = {
enable = true; mimeApps = {
defaultApplications = { enable = true;
"application/json" = "defaultEditor.desktop";
"application/pdf" = "defaultPdfViewer.desktop"; defaultApplications = {
"application/x-extension-htm" = "defaultWebBrowser.desktop"; "application/json" = "defaultEditor.desktop";
"application/x-extension-html" = "defaultWebBrowser.desktop"; "application/pdf" = "defaultPdfViewer.desktop";
"application/x-extension-shtml" = "defaultWebBrowser.desktop"; "application/x-extension-htm" = "defaultWebBrowser.desktop";
"application/x-extension-xht" = "defaultWebBrowser.desktop"; "application/x-extension-html" = "defaultWebBrowser.desktop";
"application/x-extension-xhtml" = "defaultWebBrowser.desktop"; "application/x-extension-shtml" = "defaultWebBrowser.desktop";
"application/x-shellscript" = "defaultEditor.desktop"; "application/x-extension-xht" = "defaultWebBrowser.desktop";
"application/xhtml+xml" = "defaultWebBrowser.desktop"; "application/x-extension-xhtml" = "defaultWebBrowser.desktop";
"audio/aac" = "defaultAudioPlayer.desktop"; "application/x-shellscript" = "defaultEditor.desktop";
"audio/flac" = "defaultAudioPlayer.desktop"; "application/xhtml+xml" = "defaultWebBrowser.desktop";
"audio/mpeg" = "defaultAudioPlayer.desktop"; "audio/aac" = "defaultAudioPlayer.desktop";
"audio/ogg" = "defaultAudioPlayer.desktop"; "audio/flac" = "defaultAudioPlayer.desktop";
"audio/opus" = "defaultAudioPlayer.desktop"; "audio/mpeg" = "defaultAudioPlayer.desktop";
"audio/wav" = "defaultAudioPlayer.desktop"; "audio/ogg" = "defaultAudioPlayer.desktop";
"audio/webm" = "defaultAudioPlayer.desktop"; "audio/opus" = "defaultAudioPlayer.desktop";
"image/gif" = "defaultImageViewer.desktop"; "audio/wav" = "defaultAudioPlayer.desktop";
"image/jpeg" = "defaultImageViewer.desktop"; "audio/webm" = "defaultAudioPlayer.desktop";
"image/png" = "defaultImageViewer.desktop"; "image/gif" = "defaultImageViewer.desktop";
"image/svg+xml" = "defaultImageViewer.desktop"; "image/jpeg" = "defaultImageViewer.desktop";
"image/tiff" = "defaultImageViewer.desktop"; "image/png" = "defaultImageViewer.desktop";
"image/webp" = "defaultImageViewer.desktop"; "image/svg+xml" = "defaultImageViewer.desktop";
"inode/directory" = "defaultFileManager.desktop"; "image/tiff" = "defaultImageViewer.desktop";
"text/html" = "defaultWebBrowser.desktop"; "image/webp" = "defaultImageViewer.desktop";
"text/markdown" = "defaultEditor.desktop"; "inode/directory" = "defaultFileManager.desktop";
"text/plain" = "defaultEditor.desktop"; "text/html" = "defaultWebBrowser.desktop";
"text/x-python" = "defaultEditor.desktop"; "text/markdown" = "defaultEditor.desktop";
"text/xml" = "defaultWebBrowser.desktop"; "text/plain" = "defaultEditor.desktop";
"video/mp2t" = "defaultVideoPlayer.desktop"; "text/x-python" = "defaultEditor.desktop";
"video/mp4" = "defaultVideoPlayer.desktop"; "text/xml" = "defaultWebBrowser.desktop";
"video/mpeg" = "defaultVideoPlayer.desktop"; "video/mp2t" = "defaultVideoPlayer.desktop";
"video/ogg" = "defaultVideoPlayer.desktop"; "video/mp4" = "defaultVideoPlayer.desktop";
"video/webm" = "defaultVideoPlayer.desktop"; "video/mpeg" = "defaultVideoPlayer.desktop";
"video/x-msvideo" = "defaultVideoPlayer.desktop"; "video/ogg" = "defaultVideoPlayer.desktop";
"x-scheme-handler/chrome" = "defaultWebBrowser.desktop"; "video/webm" = "defaultVideoPlayer.desktop";
"x-scheme-handler/ftp" = "defaultWebBrowser.desktop"; "video/x-msvideo" = "defaultVideoPlayer.desktop";
"x-scheme-handler/http" = "defaultWebBrowser.desktop"; "x-scheme-handler/chrome" = "defaultWebBrowser.desktop";
"x-scheme-handler/https" = "defaultWebBrowser.desktop"; "x-scheme-handler/ftp" = "defaultWebBrowser.desktop";
"x-scheme-handler/http" = "defaultWebBrowser.desktop";
"x-scheme-handler/https" = "defaultWebBrowser.desktop";
};
};
desktopEntries = let
mkDefaultEntry = name: package: {
name = "Default ${name}";
exec = "${lib.getExe package} %U";
terminal = false;
settings = {
NoDisplay = "true";
};
};
in {
defaultAudioPlayer = mkDefaultEntry "Audio Player" config.ar.home.defaultApps.audioPlayer;
defaultEditor = mkDefaultEntry "Editor" config.ar.home.defaultApps.editor;
defaultFileManager = mkDefaultEntry "File Manager" config.ar.home.defaultApps.fileManager;
defaultImageViewer = mkDefaultEntry "Image Viewer" config.ar.home.defaultApps.imageViewer;
defaultPdfViewer = mkDefaultEntry "PDF Viewer" config.ar.home.defaultApps.pdfViewer;
defaultVideoPlayer = mkDefaultEntry "Video Player" config.ar.home.defaultApps.videoPlayer;
defaultWebBrowser = mkDefaultEntry "Web Browser" config.ar.home.defaultApps.webBrowser;
}; };
};
home.sessionVariables = {
BROWSER = "${lib.getExe config.ar.home.defaultApps.webBrowser}";
EDITOR = "${lib.getExe config.ar.home.defaultApps.terminalEditor}";
TERMINAL = "${lib.getExe config.ar.home.defaultApps.terminal}";
}; };
}; };
} }