sherlock: add systemd.enable option (#7678)
Add the ability to run sherlock as a daemon through systemd.
This commit is contained in:
parent
11626a4383
commit
2a749f4790
1 changed files with 16 additions and 0 deletions
|
|
@ -52,6 +52,8 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
systemd.enable = lib.mkEnableOption "sherlock as a daemon";
|
||||
|
||||
aliases = mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = { };
|
||||
|
|
@ -125,18 +127,22 @@ in
|
|||
|
||||
xdg.configFile = {
|
||||
"sherlock/config.toml" = mkIf (cfg.settings != { }) {
|
||||
onChange = mkIf cfg.systemd.enable "${lib.getExe' pkgs.systemd "systemctl"} --user restart sherlock.service";
|
||||
source = tomlFormat.generate "sherlock-config.toml" cfg.settings;
|
||||
};
|
||||
|
||||
"sherlock/sherlock_alias.json" = mkIf (cfg.aliases != { }) {
|
||||
onChange = mkIf cfg.systemd.enable "${lib.getExe' pkgs.systemd "systemctl"} --user restart sherlock.service";
|
||||
source = jsonFormat.generate "sherlock_alias.json" cfg.aliases;
|
||||
};
|
||||
|
||||
"sherlock/fallback.json" = mkIf (cfg.launchers != [ ]) {
|
||||
onChange = mkIf cfg.systemd.enable "${lib.getExe' pkgs.systemd "systemctl"} --user restart sherlock.service";
|
||||
source = jsonFormat.generate "sherlock-fallback.json" cfg.launchers;
|
||||
};
|
||||
|
||||
"sherlock/sherlockignore" = mkIf (cfg.ignore != "") {
|
||||
onChange = mkIf cfg.systemd.enable "${lib.getExe' pkgs.systemd "systemctl"} --user restart sherlock.service";
|
||||
text = cfg.ignore;
|
||||
};
|
||||
|
||||
|
|
@ -144,5 +150,15 @@ in
|
|||
text = cfg.style;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.sherlock = lib.mkIf cfg.systemd.enable {
|
||||
Unit.Description = "Sherlock - App Launcher";
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
Service = {
|
||||
Environment = [ "DISPLAY=:0" ];
|
||||
ExecStart = "${lib.getExe cfg.package} --daemonize";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue