This adds the wlsunset module, a program for day/night gamma adjustments on wayland. Fixes #1625wip/yesman
parent
44f9d68d8c
commit
33407189c1
@ -0,0 +1,97 @@ |
||||
{ config, lib, pkgs, ... }: |
||||
|
||||
with lib; |
||||
|
||||
let cfg = config.services.wlsunset; |
||||
|
||||
in { |
||||
meta.maintainers = [ maintainers.matrss ]; |
||||
|
||||
options.services.wlsunset = { |
||||
enable = mkEnableOption "Whether to enable wlsunset."; |
||||
|
||||
package = mkOption { |
||||
type = types.package; |
||||
default = pkgs.wlsunset; |
||||
defaultText = "pkgs.wlsunset"; |
||||
description = '' |
||||
wlsunset derivation to use. |
||||
''; |
||||
}; |
||||
|
||||
latitude = mkOption { |
||||
type = types.str; |
||||
description = '' |
||||
Your current latitude, between <literal>-90.0</literal> and |
||||
<literal>90.0</literal>. |
||||
''; |
||||
}; |
||||
|
||||
longitude = mkOption { |
||||
type = types.str; |
||||
description = '' |
||||
Your current longitude, between <literal>-180.0</literal> and |
||||
<literal>180.0</literal>. |
||||
''; |
||||
}; |
||||
|
||||
temperature = { |
||||
day = mkOption { |
||||
type = types.int; |
||||
default = 6500; |
||||
description = '' |
||||
Colour temperature to use during the day, in Kelvin (K). |
||||
This value must be greater than <literal>temperature.night</literal>. |
||||
''; |
||||
}; |
||||
|
||||
night = mkOption { |
||||
type = types.int; |
||||
default = 4000; |
||||
description = '' |
||||
Colour temperature to use during the night, in Kelvin (K). |
||||
This value must be smaller than <literal>temperature.day</literal>. |
||||
''; |
||||
}; |
||||
}; |
||||
|
||||
gamma = mkOption { |
||||
type = types.str; |
||||
default = "1.0"; |
||||
description = '' |
||||
Gamma value to use. |
||||
''; |
||||
}; |
||||
|
||||
systemdTarget = mkOption { |
||||
type = types.str; |
||||
default = "graphical-session.target"; |
||||
description = '' |
||||
Systemd target to bind to. |
||||
''; |
||||
}; |
||||
}; |
||||
|
||||
config = mkIf cfg.enable { |
||||
systemd.user.services.wlsunset = { |
||||
Unit = { |
||||
Description = "Day/night gamma adjustments for Wayland compositors."; |
||||
PartOf = [ "graphical-session.target" ]; |
||||
}; |
||||
|
||||
Service = { |
||||
ExecStart = let |
||||
args = [ |
||||
"-l ${cfg.latitude}" |
||||
"-L ${cfg.longitude}" |
||||
"-t ${toString cfg.temperature.night}" |
||||
"-T ${toString cfg.temperature.day}" |
||||
"-g ${cfg.gamma}" |
||||
]; |
||||
in "${cfg.package}/bin/wlsunset ${concatStringsSep " " args}"; |
||||
}; |
||||
|
||||
Install = { WantedBy = [ cfg.systemdTarget ]; }; |
||||
}; |
||||
}; |
||||
} |
@ -0,0 +1 @@ |
||||
{ wlsunset-service = ./wlsunset-service.nix; } |
@ -0,0 +1,9 @@ |
||||
[Install] |
||||
WantedBy=test.target |
||||
|
||||
[Service] |
||||
ExecStart=@wlsunset@/bin/wlsunset -l 12.3 -L 128.8 -t 3500 -T 6000 -g 0.6 |
||||
|
||||
[Unit] |
||||
Description=Day/night gamma adjustments for Wayland compositors. |
||||
PartOf=graphical-session.target |
@ -0,0 +1,25 @@ |
||||
{ config, pkgs, ... }: |
||||
|
||||
{ |
||||
config = { |
||||
services.wlsunset = { |
||||
enable = true; |
||||
package = pkgs.writeScriptBin "dummy-wlsunset" "" // { |
||||
outPath = "@wlsunset@"; |
||||
}; |
||||
latitude = "12.3"; |
||||
longitude = "128.8"; |
||||
temperature.day = 6000; |
||||
temperature.night = 3500; |
||||
gamma = "0.6"; |
||||
systemdTarget = "test.target"; |
||||
}; |
||||
|
||||
nmt.script = '' |
||||
serviceFile=home-files/.config/systemd/user/wlsunset.service |
||||
|
||||
assertFileExists $serviceFile |
||||
assertFileContent $serviceFile ${./wlsunset-service-expected.service} |
||||
''; |
||||
}; |
||||
} |
Loading…
Reference in new issue