nixcfg/homeManagerModules/defaultApps.nix

109 lines
3.1 KiB
Nix
Raw Permalink 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;
2024-07-19 22:18:22 -04:00
mimeTypes = import ./mimeTypes.nix;
2024-07-07 22:23:19 -04:00
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 = "${builtins.baseNameOf (lib.getExe cfg.webBrowser)}";
EDITOR = "${builtins.baseNameOf (lib.getExe cfg.terminalEditor)}";
TERMINAL = "${builtins.baseNameOf (lib.getExe cfg.terminal)}";
};
2024-07-07 22:23:19 -04:00
};
2024-07-07 22:23:19 -04:00
xdg = {
configFile."xfce4/helpers.rc".text = ''
FileManager=${builtins.baseNameOf (lib.getExe cfg.fileManager)}
TerminalEmulator=${builtins.baseNameOf (lib.getExe cfg.terminal)}
WebBrowser=${builtins.baseNameOf (lib.getExe cfg.webBrowser)}
'';
mimeApps = lib.mkIf cfg.forceMimeAssociations {
2024-07-07 22:23:19 -04:00
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 =
2024-07-19 22:18:22 -04:00
mkDefaults mimeTypes.audioFiles
2024-07-07 22:23:19 -04:00
"defaultAudioPlayer.desktop";
2024-07-07 22:23:19 -04:00
browserTypes =
2024-07-19 22:18:22 -04:00
mkDefaults mimeTypes.browserFiles
2024-07-07 22:23:19 -04:00
"defaultWebBrowser.desktop";
2024-07-07 22:23:19 -04:00
documentTypes =
2024-07-19 22:18:22 -04:00
mkDefaults mimeTypes.documentFiles
2024-07-07 22:23:19 -04:00
"defaultPdfViewer.desktop";
2024-07-07 22:23:19 -04:00
editorTypes =
2024-07-19 22:18:22 -04:00
mkDefaults mimeTypes.editorFiles
2024-07-07 22:23:19 -04:00
"defaultEditor.desktop";
2024-07-07 22:23:19 -04:00
folderTypes = {"inode/directory" = "defaultFileManager.desktop";};
2024-07-07 22:23:19 -04:00
imageTypes =
2024-07-19 22:18:22 -04:00
mkDefaults mimeTypes.imageFiles
2024-07-07 22:23:19 -04:00
"defaultImageViewer.desktop";
2024-07-07 22:23:19 -04:00
videoTypes =
2024-07-19 22:18:22 -04:00
mkDefaults mimeTypes.videoFiles
2024-07-07 22:23:19 -04:00
"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: {
exec = "${lib.getExe package} %U";
2024-10-24 14:45:55 -04:00
icon = "${builtins.baseNameOf (lib.getExe package)}";
name = "Default ${name}";
2024-07-07 22:23:19 -04:00
terminal = false;
2024-10-24 14:45:55 -04:00
2024-07-07 22:23:19 -04:00
settings = {
NoDisplay = "true";
2024-06-29 22:02:23 -04:00
};
};
in
lib.mkIf cfg.forceMimeAssociations {
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
};
}