nixcfg/homeManagerModules/defaultApps.nix

108 lines
2.7 KiB
Nix
Raw Normal View History

{
config,
2024-06-29 22:02:23 -04:00
lib,
...
2024-07-07 22:23:19 -04:00
}: let
cfg = config.ar.home.defaultApps;
inherit
(import ./mimetypes.nix)
audioFiles
browserFiles
documentFiles
editorFiles
imageFiles
videoFiles
;
in {
config = lib.mkIf cfg.enable {
dconf = {
enable = true;
settings = {
"org/cinnamon/desktop/applications/terminal".exec = "${lib.getExe cfg.terminal}";
"org/cinnamon/desktop/default-applications/terminal".exec = "${lib.getExe cfg.terminal}";
};
2024-07-07 22:23:19 -04:00
};
2024-07-07 22:23:19 -04:00
home = {
packages = with cfg; [
audioPlayer
editor
fileManager
imageViewer
pdfViewer
terminal
terminalEditor
videoPlayer
webBrowser
];
2024-06-29 22:02:23 -04:00
2024-07-07 22:23:19 -04:00
sessionVariables = {
BROWSER = "${lib.getExe cfg.webBrowser}";
EDITOR = "${lib.getExe cfg.terminalEditor}";
TERMINAL = "${lib.getExe cfg.terminal}";
};
2024-07-07 22:23:19 -04:00
};
2024-07-07 22:23:19 -04:00
xdg = {
mimeApps = {
enable = true;
2024-06-29 22:02:23 -04:00
2024-07-07 22:23:19 -04:00
defaultApplications = let
mkDefaults = files: desktopFile: lib.genAttrs files (_: [desktopFile]);
audioTypes =
mkDefaults audioFiles
"defaultAudioPlayer.desktop";
2024-07-07 22:23:19 -04:00
browserTypes =
mkDefaults browserFiles
"defaultWebBrowser.desktop";
2024-07-07 22:23:19 -04:00
documentTypes =
mkDefaults documentFiles
"defaultPdfViewer.desktop";
2024-07-07 22:23:19 -04:00
editorTypes =
mkDefaults editorFiles
"defaultEditor.desktop";
2024-07-07 22:23:19 -04:00
folderTypes = {"inode/directory" = "defaultFileManager.desktop";};
2024-07-07 22:23:19 -04:00
imageTypes =
mkDefaults imageFiles
"defaultImageViewer.desktop";
2024-07-07 22:23:19 -04:00
videoTypes =
mkDefaults videoFiles
"defaultVideoPlayer.desktop";
in
audioTypes
// browserTypes
// documentTypes
// editorTypes
// folderTypes
// imageTypes
// videoTypes;
};
2024-06-29 22:02:23 -04:00
2024-07-07 22:23:19 -04:00
desktopEntries = let
mkDefaultEntry = name: package: {
name = "Default ${name}";
exec = "${lib.getExe package} %U";
terminal = false;
settings = {
NoDisplay = "true";
2024-06-29 22:02:23 -04:00
};
};
2024-07-07 22:23:19 -04:00
in {
defaultAudioPlayer = mkDefaultEntry "Audio Player" cfg.audioPlayer;
defaultEditor = mkDefaultEntry "Editor" cfg.editor;
defaultFileManager = mkDefaultEntry "File Manager" cfg.fileManager;
defaultImageViewer = mkDefaultEntry "Image Viewer" cfg.imageViewer;
defaultPdfViewer = mkDefaultEntry "PDF Viewer" cfg.pdfViewer;
defaultVideoPlayer = mkDefaultEntry "Video Player" cfg.videoPlayer;
defaultWebBrowser = mkDefaultEntry "Web Browser" cfg.webBrowser;
};
};
2024-07-07 22:23:19 -04:00
};
}