diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index faa4a31fa..4ad9b3753 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -376,6 +376,8 @@ Makefile @thiagokokada /modules/services/barrier.nix @Kritnich /tests/modules/services/barrier @Kritnich +/modules/services/batsignal.nix @Kranzes + /modules/services/betterlockscreen.nix @SebTM /modules/programs/borgmatic.nix @DamienCassou diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c3335fcbe..c2bbedd42 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -979,6 +979,14 @@ in A new module is available: 'programs.hstr'. ''; } + + { + time = "2023-04-18T06:28:31+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.batsignal'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 0e60bb59f..a6312bfd1 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -208,6 +208,7 @@ let ./services/autorandr.nix ./services/avizo.nix ./services/barrier.nix + ./services/batsignal.nix ./services/betterlockscreen.nix ./services/blueman-applet.nix ./services/borgmatic.nix diff --git a/modules/services/batsignal.nix b/modules/services/batsignal.nix new file mode 100644 index 000000000..4f209f1e0 --- /dev/null +++ b/modules/services/batsignal.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, ... }: + +let + + cfg = config.services.batsignal; + +in { + meta.maintainers = with lib.maintainers; [ kranzes ]; + + options = { + services.batsignal = { + enable = lib.mkEnableOption "Batsignal Battery Daemon"; + + package = lib.mkPackageOption pkgs "batsignal" { }; + + extraArgs = lib.mkOption { + type = with lib.types; listOf str; + default = [ ]; + description = '' + Extra arguments to be passed to the batsignal executable. + ''; + }; + }; + }; + + config = lib.mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.batsignal" pkgs + lib.platforms.linux) + ]; + + systemd.user.services.batsignal = { + Unit = { + Description = "batsignal - battery monitor daemon"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "simple"; + ExecStart = + "${lib.getExe cfg.package} ${lib.escapeShellArgs cfg.extraArgs}"; + Restart = "on-failure"; + RestartSec = 1; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + }; + }; +}