diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni index d9dc010c..acb0b531 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -94,6 +94,14 @@ opt = f opt/long = fade-fast opt/arg = none +[fade/duration] +type = unsigned_long +description = Set length of the fade duration in full seconds for fading between color temperatures. +default = 4 +example = 5 +opt/long = fade-duration +opt/arg = required + [brightness/day] type = float description = The screen brightness during daytime. If both day and night brightness are set, these will overrule the value of brightness. diff --git a/src/options.c b/src/options.c index f56a66ed..06434b81 100644 --- a/src/options.c +++ b/src/options.c @@ -93,8 +93,8 @@ static void print_method_list(const gamma_method_t *gamma_methods) { if (gamma_methods[0].name == NULL) { - printf("This build of redshift contains no adjustment methods that work on your system!"); - return; + printf("This build of redshift contains no adjustment methods that work on your system!"); + return; } fputs(_("Available adjustment methods in this build of redshift:\n"), stdout); @@ -112,8 +112,8 @@ static void print_provider_list(const location_provider_t location_providers[]) { if (location_providers[0].name == NULL) { - printf("This build of redshift contains no adjustment methods that work on your system!"); - return; + printf("This build of redshift contains no adjustment methods that work on your system!"); + return; } fputs(_("Available location providers in this build of redshift:\n"), stdout); @@ -171,10 +171,10 @@ find_location_provider( */ int options_load_from_elektra( - options_t *options, - Elektra *elektra, - const gamma_method_t *gamma_methods, - const location_provider_t *location_providers) { + options_t *options, + Elektra *elektra, + const gamma_method_t *gamma_methods, + const location_provider_t *location_providers) { /** * Before using Elektra, there were two sources for configuration: CLI options and config file. * From redshift's point of view there is only one source now, namely Elektra. @@ -189,8 +189,8 @@ options_load_from_elektra( // Version if (elektraGetVersion(elektra)) { - printf("%s\n", PACKAGE_STRING); - return -1; + printf("%s\n", PACKAGE_STRING); + return -1; } // Verbose @@ -302,6 +302,8 @@ options_load_from_elektra( // Fade options->use_fade = !elektraGetFadeFast(elektra); + + options->fade_duration = elektraGetFadeDuration(elektra); // Temperature options->scheme.day.temperature = elektraGetTempDay(elektra); @@ -378,6 +380,7 @@ options_init(options_t *options) options->provider = NULL; options->use_fade = -1; + options->fade_duration = -1; options->preserve_gamma = 1; options->mode = ELEKTRA_ENUM_MODE_CONTINUAL; options->verbose = 0; diff --git a/src/options.h b/src/options.h index 34b43126..edc175ee 100644 --- a/src/options.h +++ b/src/options.h @@ -27,38 +27,35 @@ typedef struct { /* Path to config file */ char *config_filepath; + /* + * For description of these options, see Elektra specification file src/elektra/redshift.ni + */ transition_scheme_t scheme; ElektraEnumMode mode; int verbose; - /* Temperature to set in manual mode. */ int temp_set; - /* Whether to fade between large skips in color temperature. */ int use_fade; - /* Whether to preserve gamma ramps if supported by gamma method. */ + long fade_duration; int preserve_gamma; - - /* Selected gamma method. */ + const gamma_method_t *method; - /* Options for adjustment methods */ - unsigned short method_crtc; - unsigned short method_screen; - unsigned short method_drm_card; - - /* Selected location provider. */ + unsigned short method_crtc; + unsigned short method_screen; + unsigned short method_drm_card; + const location_provider_t *provider; - /* Lat, lon for location provider. */ float provider_manual_arg_lat; - float provider_manual_arg_lon; + float provider_manual_arg_lon; } options_t; int options_load_from_elektra( - options_t *options, - Elektra *elektra, - const gamma_method_t *gamma_methods, - const location_provider_t *location_providers); + options_t *options, + Elektra *elektra, + const gamma_method_t *gamma_methods, + const location_provider_t *location_providers); void options_init(options_t *options); #endif /* ! REDSHIFT_OPTIONS_H */ diff --git a/src/redshift.c b/src/redshift.c index 11fb1b53..27466219 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -503,7 +503,8 @@ run_continual_mode(const location_provider_t *provider, const transition_scheme_t *scheme, const gamma_method_t *method, gamma_state_t *method_state, - int use_fade, int preserve_gamma, int verbose) + int use_fade, long fade_duration, + int preserve_gamma, int verbose) { int r; @@ -656,8 +657,9 @@ run_continual_mode(const location_provider_t *provider, color_setting_diff_is_major( &target_interp, &prev_target_interp))) { - fade_length = FADE_LENGTH; - fade_time = 0; + // Scale fade_length according to desired fade_duration. + fade_length = (FADE_LENGTH * (fade_duration * 1000)) / (FADE_LENGTH * SLEEP_DURATION_SHORT); + fade_time = 0; fade_start_interp = interp; } } @@ -1172,7 +1174,8 @@ int main(int argc, const char * const *argv, const char * const *envp) r = run_continual_mode( options.provider, location_state, scheme, options.method, method_state, - options.use_fade, options.preserve_gamma, + options.use_fade, options.fade_duration, + options.preserve_gamma, options.verbose); if (r < 0) exit(EXIT_FAILURE); }