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,11 +1,20 @@
{
pkgs,
lib,
config,
lib,
pkgs,
...
}: {
config = lib.mkIf config.ar.home.defaultApps.enable {
home.packages = with config.ar.home.defaultApps; [
dconf = {
enable = true;
settings = {
"org/cinnamon/desktop/applications/terminal".exec = "${lib.getExe config.ar.home.defaultApps.terminal}";
"org/cinnamon/desktop/default-applications/terminal".exec = "${lib.getExe config.ar.home.defaultApps.terminal}";
};
};
home = {
packages = with config.ar.home.defaultApps; [
audioPlayer
editor
fileManager
@ -17,35 +26,17 @@
webBrowser
];
dconf = {
enable = true;
settings = {
"org/cinnamon/desktop/applications/terminal".exec = "${lib.getExe config.ar.home.defaultApps.terminal}";
"org/cinnamon/desktop/default-applications/terminal".exec = "${lib.getExe config.ar.home.defaultApps.terminal}";
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}";
};
};
xdg.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;
};
xdg.mimeApps = {
xdg = {
mimeApps = {
enable = true;
defaultApplications = {
"application/json" = "defaultEditor.desktop";
"application/pdf" = "defaultPdfViewer.desktop";
@ -87,10 +78,25 @@
"x-scheme-handler/https" = "defaultWebBrowser.desktop";
};
};
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}";
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;
};
};
};
}