diff --git a/modules/services/hyprsunset.nix b/modules/services/hyprsunset.nix index b4ff7ea01..724b3ce86 100644 --- a/modules/services/hyprsunset.nix +++ b/modules/services/hyprsunset.nix @@ -36,13 +36,15 @@ in example = "*-*-* 06:00:00"; }; - extraArgs = lib.mkOption { - type = lib.types.listOf lib.types.str; + requests = lib.mkOption { + type = lib.types.listOf (lib.types.listOf lib.types.str); default = [ ]; - description = "Additional command-line arguments to pass to `hyprctl hyprsunset` for this transition."; - example = [ - "temperature 3500" - ]; + description = "List of requests to pass to `hyprctl hyprsunset` for this transition. Each inner list represents a separate command."; + example = lib.literalExpression '' + [ + [ "temperature" "3500" ] + ] + ''; }; }; } @@ -53,11 +55,16 @@ in { sunrise = { calendar = "*-*-* 06:00:00"; - extraArgs = [ "temperature" "6500" ]; + requests = [ + [ "temperature" "6500" ] + [ "gamma 100" ] + ]; }; sunset = { calendar = "*-*-* 19:00:00"; - extraArgs = [ "temperature" "3500" ]; + requests = [ + [ "temperature" "3500" ] + ]; }; } ''; @@ -69,7 +76,7 @@ in let # Create the main persistent service that maintains the IPC socket # Create a service for each transition in the transitions configuration - # These services will send commands to the persistent service via IPC + # These services will send requests to the persistent service via IPC transitionServices = lib.mapAttrs' ( name: transitionCfg: lib.nameValuePair "hyprsunset-${name}" { @@ -83,8 +90,12 @@ in }; Service = { - ExecStart = "${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} hyprsunset ${lib.escapeShellArgs transitionCfg.extraArgs}"; Type = "oneshot"; + # Execute multiple requests sequentially + ExecStart = lib.concatMapStringsSep " && " ( + cmd: + "${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} hyprsunset ${lib.escapeShellArgs cmd}" + ) transitionCfg.requests; }; } ) cfg.transitions; diff --git a/tests/modules/services/hyprsunset/basic-configuration.nix b/tests/modules/services/hyprsunset/basic-configuration.nix index a0ce02abd..fbb520933 100644 --- a/tests/modules/services/hyprsunset/basic-configuration.nix +++ b/tests/modules/services/hyprsunset/basic-configuration.nix @@ -6,12 +6,15 @@ transitions = { sunrise = { calendar = "*-*-* 06:30:00"; - extraArgs = [ "temperature 6500" ]; + requests = [ + [ "temperature 6500" ] + [ "identity" ] + ]; }; sunset = { calendar = "*-*-* 19:30:00"; - extraArgs = [ "temperature 3500" ]; + requests = [ [ "temperature 3500" ] ]; }; }; }; @@ -38,7 +41,7 @@ assertFileContains $sunsetTimer "OnCalendar=*-*-* 19:30:00" # Verify service configurations - assertFileContains $sunriseService "ExecStart=@hyprland@/bin/hyprctl hyprsunset 'temperature 6500'" + assertFileContains $sunriseService "ExecStart=@hyprland@/bin/hyprctl hyprsunset 'temperature 6500' && @hyprland@/bin/hyprctl hyprsunset identity" assertFileContains $sunsetService "ExecStart=@hyprland@/bin/hyprctl hyprsunset 'temperature 3500'" ''; }