mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
xdg-autostart: add module
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
e83414058e
commit
cc31834769
4 changed files with 62 additions and 0 deletions
40
modules/misc/xdg-autostart.nix
Normal file
40
modules/misc/xdg-autostart.nix
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (builtins) baseNameOf listToAttrs map unsafeDiscardStringContext;
|
||||||
|
inherit (lib) literalExpression mkEnableOption mkIf mkOption types;
|
||||||
|
|
||||||
|
cfg = config.xdg.autostart;
|
||||||
|
|
||||||
|
/* "/nix/store/x-foo/application.desktop" -> {
|
||||||
|
name = "autostart/application.desktop";
|
||||||
|
value = { source = "/nix/store/x-foo/application.desktop"; };
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
mapDesktopEntry = entry: {
|
||||||
|
name = "autostart/${unsafeDiscardStringContext (baseNameOf entry)}";
|
||||||
|
value.source = entry;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
meta.maintainers = with lib.maintainers; [ Scrumplex ];
|
||||||
|
|
||||||
|
options.xdg.autostart = {
|
||||||
|
enable = mkEnableOption "creation of XDG autostart entries";
|
||||||
|
|
||||||
|
entries = mkOption {
|
||||||
|
type = with types; listOf path;
|
||||||
|
description = ''
|
||||||
|
Paths to desktop files that should be linked to `XDG_CONFIG_HOME/autostart`
|
||||||
|
'';
|
||||||
|
default = [ ];
|
||||||
|
example = literalExpression ''
|
||||||
|
[
|
||||||
|
"''${pkgs.evolution}/share/applications/org.gnome.Evolution.desktop"
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf (cfg.enable && cfg.entries != [ ]) {
|
||||||
|
xdg.configFile = listToAttrs (map mapDesktopEntry cfg.entries);
|
||||||
|
};
|
||||||
|
}
|
|
@ -42,6 +42,7 @@ let
|
||||||
./misc/uninstall.nix
|
./misc/uninstall.nix
|
||||||
./misc/version.nix
|
./misc/version.nix
|
||||||
./misc/vte.nix
|
./misc/vte.nix
|
||||||
|
./misc/xdg-autostart.nix
|
||||||
./misc/xdg-desktop-entries.nix
|
./misc/xdg-desktop-entries.nix
|
||||||
./misc/xdg-mime-apps.nix
|
./misc/xdg-mime-apps.nix
|
||||||
./misc/xdg-mime.nix
|
./misc/xdg-mime.nix
|
||||||
|
|
20
tests/modules/misc/xdg/autostart.nix
Normal file
20
tests/modules/misc/xdg/autostart.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
config = {
|
||||||
|
xdg.autostart = {
|
||||||
|
enable = true;
|
||||||
|
entries = [
|
||||||
|
"${pkgs.evolution}/share/applications/org.gnome.Evolution.desktop"
|
||||||
|
"${pkgs.tdesktop}/share/applications/org.telegram.desktop.desktop"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/autostart/org.gnome.Evolution.desktop
|
||||||
|
assertFileContent home-files/.config/autostart/org.gnome.Evolution.desktop \
|
||||||
|
${pkgs.evolution}/share/applications/org.gnome.Evolution.desktop
|
||||||
|
assertFileExists home-files/.config/autostart/org.telegram.desktop.desktop
|
||||||
|
assertFileContent home-files/.config/autostart/org.telegram.desktop.desktop \
|
||||||
|
${pkgs.tdesktop}/share/applications/org.telegram.desktop.desktop
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -9,4 +9,5 @@
|
||||||
xdg-mime = ./mime.nix;
|
xdg-mime = ./mime.nix;
|
||||||
xdg-mime-disabled = ./mime-disabled.nix;
|
xdg-mime-disabled = ./mime-disabled.nix;
|
||||||
xdg-mime-package = ./mime-packages.nix;
|
xdg-mime-package = ./mime-packages.nix;
|
||||||
|
xdg-autostart = ./autostart.nix;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue