mirror of
https://github.com/nix-community/home-manager
synced 2024-12-18 15:59:48 +01:00
wlsunset: update options
This commit is contained in:
parent
fdaaf543ba
commit
3dfe05aa9b
2 changed files with 67 additions and 17 deletions
|
@ -11,7 +11,7 @@ in {
|
||||||
enable = mkEnableOption "wlsunset";
|
enable = mkEnableOption "wlsunset";
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = with types; package;
|
||||||
default = pkgs.wlsunset;
|
default = pkgs.wlsunset;
|
||||||
defaultText = "pkgs.wlsunset";
|
defaultText = "pkgs.wlsunset";
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -20,7 +20,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
latitude = mkOption {
|
latitude = mkOption {
|
||||||
type = types.str;
|
type = with types; nullOr (either str (either float int));
|
||||||
|
default = null;
|
||||||
|
example = -74.3;
|
||||||
description = ''
|
description = ''
|
||||||
Your current latitude, between `-90.0` and
|
Your current latitude, between `-90.0` and
|
||||||
`90.0`.
|
`90.0`.
|
||||||
|
@ -28,7 +30,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
longitude = mkOption {
|
longitude = mkOption {
|
||||||
type = types.str;
|
type = with types; nullOr (either str (either float int));
|
||||||
|
default = null;
|
||||||
|
example = 12.5;
|
||||||
description = ''
|
description = ''
|
||||||
Your current longitude, between `-180.0` and
|
Your current longitude, between `-180.0` and
|
||||||
`180.0`.
|
`180.0`.
|
||||||
|
@ -37,7 +41,7 @@ in {
|
||||||
|
|
||||||
temperature = {
|
temperature = {
|
||||||
day = mkOption {
|
day = mkOption {
|
||||||
type = types.int;
|
type = with types; int;
|
||||||
default = 6500;
|
default = 6500;
|
||||||
description = ''
|
description = ''
|
||||||
Colour temperature to use during the day, in Kelvin (K).
|
Colour temperature to use during the day, in Kelvin (K).
|
||||||
|
@ -46,7 +50,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
night = mkOption {
|
night = mkOption {
|
||||||
type = types.int;
|
type = with types; int;
|
||||||
default = 4000;
|
default = 4000;
|
||||||
description = ''
|
description = ''
|
||||||
Colour temperature to use during the night, in Kelvin (K).
|
Colour temperature to use during the night, in Kelvin (K).
|
||||||
|
@ -56,15 +60,42 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
gamma = mkOption {
|
gamma = mkOption {
|
||||||
type = types.str;
|
type = with types; (either str (either float int));
|
||||||
default = "1.0";
|
default = 1.0;
|
||||||
|
example = 0.6;
|
||||||
description = ''
|
description = ''
|
||||||
Gamma value to use.
|
Gamma value to use.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
output = mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Name of output to use, by default all outputs are used.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
sunrise = mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
default = null;
|
||||||
|
example = "06:30";
|
||||||
|
description = ''
|
||||||
|
The time when the sun rises (in 24 hour format).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
sunset = mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
default = null;
|
||||||
|
example = "18:00";
|
||||||
|
description = ''
|
||||||
|
The time when the sun sets (in 24 hour format).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
systemdTarget = mkOption {
|
systemdTarget = mkOption {
|
||||||
type = types.str;
|
type = with types; str;
|
||||||
default = "graphical-session.target";
|
default = "graphical-session.target";
|
||||||
description = ''
|
description = ''
|
||||||
Systemd target to bind to.
|
Systemd target to bind to.
|
||||||
|
@ -76,6 +107,22 @@ in {
|
||||||
assertions = [
|
assertions = [
|
||||||
(lib.hm.assertions.assertPlatform "services.wlsunset" pkgs
|
(lib.hm.assertions.assertPlatform "services.wlsunset" pkgs
|
||||||
lib.platforms.linux)
|
lib.platforms.linux)
|
||||||
|
{
|
||||||
|
assertion = (cfg.sunrise != null || cfg.sunset != null)
|
||||||
|
!= (cfg.latitude != null || cfg.longitude != null);
|
||||||
|
message =
|
||||||
|
"Either `sunrise` and `sunset` together or `longitude` and `latitude` together must be set for wlsunset";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion = (cfg.sunrise != null) == (cfg.sunset != null);
|
||||||
|
message =
|
||||||
|
"Both `sunset` and `sunrise` together must be set for wlsunset";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion = (cfg.latitude != null) == (cfg.longitude != null);
|
||||||
|
message =
|
||||||
|
"Both `latitude and `longitude` together must be set for wlsunset";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.user.services.wlsunset = {
|
systemd.user.services.wlsunset = {
|
||||||
|
@ -86,14 +133,17 @@ in {
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
ExecStart = let
|
ExecStart = let
|
||||||
args = [
|
args = cli.toGNUCommandLineShell { } {
|
||||||
"-l ${cfg.latitude}"
|
t = cfg.temperature.night;
|
||||||
"-L ${cfg.longitude}"
|
T = cfg.temperature.day;
|
||||||
"-t ${toString cfg.temperature.night}"
|
g = cfg.gamma;
|
||||||
"-T ${toString cfg.temperature.day}"
|
l = cfg.latitude;
|
||||||
"-g ${cfg.gamma}"
|
L = cfg.longitude;
|
||||||
];
|
S = cfg.sunrise;
|
||||||
in "${cfg.package}/bin/wlsunset ${concatStringsSep " " args}";
|
s = cfg.sunset;
|
||||||
|
o = cfg.output;
|
||||||
|
};
|
||||||
|
in "${cfg.package}/bin/wlsunset ${args}";
|
||||||
};
|
};
|
||||||
|
|
||||||
Install = { WantedBy = [ cfg.systemdTarget ]; };
|
Install = { WantedBy = [ cfg.systemdTarget ]; };
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
WantedBy=test.target
|
WantedBy=test.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=@wlsunset@/bin/wlsunset -l 12.3 -L 128.8 -t 3500 -T 6000 -g 0.6
|
ExecStart=@wlsunset@/bin/wlsunset '-L' '128.8' '-T' '6000' '-g' '0.6' '-l' '12.3' '-t' '3500'
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Day/night gamma adjustments for Wayland compositors.
|
Description=Day/night gamma adjustments for Wayland compositors.
|
||||||
|
|
Loading…
Reference in a new issue