diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bf5690b4..4b72b0fd 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -225,6 +225,8 @@ /modules/services/playerctld.nix @fendse /tests/modules/playerctld @fendse +/modules/services/poweralertd.nix @ThibautMarty + /modules/services/pulseeffects.nix @jonringer /modules/services/random-background.nix @rycee diff --git a/modules/misc/news.nix b/modules/misc/news.nix index cf32e0a0..a07efa1f 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1906,6 +1906,14 @@ in ''; } + { + time = "2021-04-26T07:00:00+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new service is available: 'services.poweralertd'. + ''; + } + ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 76e79669..e9334d1b 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -181,6 +181,7 @@ let (loadModule ./services/plan9port.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/playerctld.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/polybar.nix { }) + (loadModule ./services/poweralertd.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/pulseeffects.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/random-background.nix { }) (loadModule ./services/redshift-gammastep/redshift.nix { }) diff --git a/modules/services/poweralertd.nix b/modules/services/poweralertd.nix new file mode 100644 index 00000000..39fffd7c --- /dev/null +++ b/modules/services/poweralertd.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.poweralertd; + +in { + meta.maintainers = [ maintainers.thibautmarty ]; + + options.services.poweralertd.enable = + mkEnableOption "the Upower-powered power alerterd"; + + config = mkIf cfg.enable { + systemd.user.services.poweralertd = { + Unit = { + Description = "UPower-powered power alerter"; + Documentation = "man:poweralertd(1)"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + + Service = { + Type = "simple"; + ExecStart = "${pkgs.poweralertd}/bin/poweralertd"; + Restart = "always"; + }; + }; + }; +}