1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

hyprsunset: support multiple commands to IPC

This commit is contained in:
Austin Horstman 2025-04-10 15:10:43 -05:00
parent cf6314f8e1
commit f1ffd097e7
2 changed files with 27 additions and 13 deletions

View file

@ -36,13 +36,15 @@ in
example = "*-*-* 06:00:00"; example = "*-*-* 06:00:00";
}; };
extraArgs = lib.mkOption { requests = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf (lib.types.listOf lib.types.str);
default = [ ]; default = [ ];
description = "Additional command-line arguments to pass to `hyprctl hyprsunset` for this transition."; description = "List of requests to pass to `hyprctl hyprsunset` for this transition. Each inner list represents a separate command.";
example = [ example = lib.literalExpression ''
"temperature 3500" [
]; [ "temperature" "3500" ]
]
'';
}; };
}; };
} }
@ -53,11 +55,16 @@ in
{ {
sunrise = { sunrise = {
calendar = "*-*-* 06:00:00"; calendar = "*-*-* 06:00:00";
extraArgs = [ "temperature" "6500" ]; requests = [
[ "temperature" "6500" ]
[ "gamma 100" ]
];
}; };
sunset = { sunset = {
calendar = "*-*-* 19:00:00"; calendar = "*-*-* 19:00:00";
extraArgs = [ "temperature" "3500" ]; requests = [
[ "temperature" "3500" ]
];
}; };
} }
''; '';
@ -69,7 +76,7 @@ in
let let
# Create the main persistent service that maintains the IPC socket # Create the main persistent service that maintains the IPC socket
# Create a service for each transition in the transitions configuration # 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' ( transitionServices = lib.mapAttrs' (
name: transitionCfg: name: transitionCfg:
lib.nameValuePair "hyprsunset-${name}" { lib.nameValuePair "hyprsunset-${name}" {
@ -83,8 +90,12 @@ in
}; };
Service = { Service = {
ExecStart = "${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} hyprsunset ${lib.escapeShellArgs transitionCfg.extraArgs}";
Type = "oneshot"; 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; ) cfg.transitions;

View file

@ -6,12 +6,15 @@
transitions = { transitions = {
sunrise = { sunrise = {
calendar = "*-*-* 06:30:00"; calendar = "*-*-* 06:30:00";
extraArgs = [ "temperature 6500" ]; requests = [
[ "temperature 6500" ]
[ "identity" ]
];
}; };
sunset = { sunset = {
calendar = "*-*-* 19:30:00"; calendar = "*-*-* 19:30:00";
extraArgs = [ "temperature 3500" ]; requests = [ [ "temperature 3500" ] ];
}; };
}; };
}; };
@ -38,7 +41,7 @@
assertFileContains $sunsetTimer "OnCalendar=*-*-* 19:30:00" assertFileContains $sunsetTimer "OnCalendar=*-*-* 19:30:00"
# Verify service configurations # 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'" assertFileContains $sunsetService "ExecStart=@hyprland@/bin/hyprctl hyprsunset 'temperature 3500'"
''; '';
} }