From 0d36b46eccd33db055a39dccb65ac7bc66667aae Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Fri, 8 Apr 2022 18:56:21 -0400 Subject: [PATCH] module: add hardware/backlight --- modules/modules/hardware/backlight.nix | 23 +++++++++++++++++++++++ modules/modules/hardware/form.nix | 1 + 2 files changed, 24 insertions(+) create mode 100644 modules/modules/hardware/backlight.nix diff --git a/modules/modules/hardware/backlight.nix b/modules/modules/hardware/backlight.nix new file mode 100644 index 0000000..715e410 --- /dev/null +++ b/modules/modules/hardware/backlight.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, inputs, ... }: +with lib; +with lib.our; +with lib.hlissner; +let + cfg = config.modules.hardware.backlight; +in +{ + options.modules.hardware.backlight = with types; { + enable = mkBoolOpt false; + initialValue = mkOpt str "50%"; + initialCommand = mkOpt str "${getMainProgram pkgs.brightnessctl} set ${cfg.initialValue}"; + }; + + config.systemd.services = mkIf cfg.enable { + "set-initial-backlight" = { + description = "Sets the initial backlight status on startup"; + wantedBy = [ "multi-user.target" ]; + serviceConfig.Type = "oneshot"; + script = cfg.initialCommand; + }; + }; +} diff --git a/modules/modules/hardware/form.nix b/modules/modules/hardware/form.nix index 5b80da0..c3f0281 100644 --- a/modules/modules/hardware/form.nix +++ b/modules/modules/hardware/form.nix @@ -21,6 +21,7 @@ in modules.hardware = { wireless.enable = mkDefault true; audio.enable = mkDefault true; + backlight.enable = mkDefault true; }; services = {