redshift: enable geoclue2

This commit is contained in:
rembo10 2018-07-13 21:54:20 +03:00 committed by Robert Helgesson
parent 092706eff8
commit 34db8df6d9
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -25,18 +25,33 @@ in
}; };
latitude = mkOption { latitude = mkOption {
type = types.str; type = types.nullOr types.str;
default = null;
description = '' description = ''
Your current latitude, between Your current latitude, between <literal>-90.0</literal> and
<literal>-90.0</literal> and <literal>90.0</literal>. <literal>90.0</literal>. Must be provided along with
longitude.
''; '';
}; };
longitude = mkOption { longitude = mkOption {
type = types.str; type = types.nullOr types.str;
default = null;
description = '' description = ''
Your current longitude, between Your current longitude, between <literal>-180.0</literal> and
between <literal>-180.0</literal> and <literal>180.0</literal>. <literal>180.0</literal>. Must be provided along with
latitude.
'';
};
provider = mkOption {
type = types.enum [ "manual" "geoclue2" ];
default = "manual";
description = ''
The location provider to use for determining your location. If set to
<literal>manual</literal> you must also provide latitude/longitude.
If set to <literal>geoclue2</literal>, you must also enable the global
geoclue2 service.
''; '';
}; };
@ -122,11 +137,17 @@ in
Service = { Service = {
ExecStart = ExecStart =
let let
providerString =
if cfg.provider == "manual"
then "${cfg.latitude}:${cfg.longitude}"
else cfg.provider;
args = [ args = [
"-l ${cfg.latitude}:${cfg.longitude}" "-l ${providerString}"
"-t ${toString cfg.temperature.day}:${toString cfg.temperature.night}" "-t ${toString cfg.temperature.day}:${toString cfg.temperature.night}"
"-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}" "-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}"
] ++ cfg.extraOptions; ] ++ cfg.extraOptions;
command = if cfg.tray then "redshift-gtk" else "redshift"; command = if cfg.tray then "redshift-gtk" else "redshift";
in in
"${cfg.package}/bin/${command} ${concatStringsSep " " args}"; "${cfg.package}/bin/${command} ${concatStringsSep " " args}";