From 34db8df6d91d8c142435d0d66bad50a6b2c090f0 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 13 Jul 2018 21:54:20 +0300 Subject: [PATCH] redshift: enable geoclue2 --- modules/services/redshift.nix | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/modules/services/redshift.nix b/modules/services/redshift.nix index 423b9fe1b..b1351dfb8 100644 --- a/modules/services/redshift.nix +++ b/modules/services/redshift.nix @@ -25,18 +25,33 @@ in }; latitude = mkOption { - type = types.str; + type = types.nullOr types.str; + default = null; description = '' - Your current latitude, between - -90.0 and 90.0. + Your current latitude, between -90.0 and + 90.0. Must be provided along with + longitude. ''; }; longitude = mkOption { - type = types.str; + type = types.nullOr types.str; + default = null; description = '' - Your current longitude, between - between -180.0 and 180.0. + Your current longitude, between -180.0 and + 180.0. 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 + manual you must also provide latitude/longitude. + If set to geoclue2, you must also enable the global + geoclue2 service. ''; }; @@ -122,11 +137,17 @@ in Service = { ExecStart = let + providerString = + if cfg.provider == "manual" + then "${cfg.latitude}:${cfg.longitude}" + else cfg.provider; + args = [ - "-l ${cfg.latitude}:${cfg.longitude}" + "-l ${providerString}" "-t ${toString cfg.temperature.day}:${toString cfg.temperature.night}" "-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}" ] ++ cfg.extraOptions; + command = if cfg.tray then "redshift-gtk" else "redshift"; in "${cfg.package}/bin/${command} ${concatStringsSep " " args}";