diff options
Diffstat (limited to 'src/redshift.c')
-rw-r--r-- | src/redshift.c | 112 |
1 files changed, 55 insertions, 57 deletions
diff --git a/src/redshift.c b/src/redshift.c index b149754..836a848 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -54,6 +54,43 @@ int poll(struct pollfd *fds, int nfds, int timeout) { abort(); return -1; } /* Length of fade in numbers of short sleep durations. */ #define FADE_LENGTH 40 + +const struct gamma_method *gamma_methods[] = { +#ifdef ENABLE_COOPGAMMA + &coopgamma_gamma_method, +#endif +#ifdef ENABLE_DRM + &drm_gamma_method, +#endif +#ifdef ENABLE_RANDR + &randr_gamma_method, +#endif +#ifdef ENABLE_VIDMODE + &vidmode_gamma_method, +#endif +#ifdef ENABLE_QUARTZ + &quartz_gamma_method, +#endif +#ifdef ENABLE_WINGDI + &w32gdi_gamma_method, +#endif + &dummy_gamma_method, + NULL +}; + + +const struct location_provider *location_providers[] = { +#ifdef ENABLE_GEOCLUE2 + &geoclue2_location_provider, +#endif +#ifdef ENABLE_CORELOCATION + &corelocation_location_provider, +#endif + &manual_location_provider, + NULL +}; + + /* Names of periods of day */ static const char *period_names[] = { /* TRANSLATORS: Name printed when period of day is unknown */ @@ -200,11 +237,11 @@ interpolate_transition_scheme(const struct transition_scheme *transition, double static int color_setting_diff_is_major(const struct color_setting *first, const struct color_setting *second) { - return (abs(first->temperature - second->temperature) > 25 || - fabs(first->brightness - second->brightness) > 0.1 || - fabs(first->gamma[0] - second->gamma[0]) > 0.1 || - fabs(first->gamma[1] - second->gamma[1]) > 0.1 || - fabs(first->gamma[2] - second->gamma[2]) > 0.1); + return abs(first->temperature - second->temperature) > 25 || + fabs(first->brightness - second->brightness) > 0.1 || + fabs(first->gamma[0] - second->gamma[0]) > 0.1 || + fabs(first->gamma[1] - second->gamma[1]) > 0.1 || + fabs(first->gamma[2] - second->gamma[2]) > 0.1; } /* Reset color setting to default values. */ @@ -329,14 +366,14 @@ method_try_start(const struct gamma_method *method, GAMMA_STATE **state, key = args; value = strchr(args, '='); if (!value) { - weprintf(_("Failed to parse option `%s'.\n"), args); /* TODO \n */ + weprintf(_("Failed to parse option `%s'."), args); return -1; } *value++ = '\0'; if (method->set_option(*state, key, value) < 0) { method->free(*state); - weprintf(_("Failed to set %s option.\n"), method->name); /* TODO \n */ + weprintf(_("Failed to set %s option."), method->name); /* TRANSLATORS: `help' must not be translated. */ weprintf(_("Try -m %s:help' for more information.\n"), method->name); /* TODO missing ` and \n */ return -1; @@ -450,12 +487,9 @@ ease_fade(double t) current time and continuously updates the screen to the appropriate color temperature. */ static void -run_continual_mode(const struct location_provider *provider, - LOCATION_STATE *location_state, - const struct transition_scheme *scheme, - const struct gamma_method *method, - GAMMA_STATE *method_state, - int use_fade, int preserve_gamma, int verbose) +run_continual_mode(const struct location_provider *provider, LOCATION_STATE *location_state, + const struct transition_scheme *scheme, const struct gamma_method *method, + GAMMA_STATE *method_state, int use_fade, int preserve_gamma, int verbose) { int done = 0; int prev_disabled = 1; @@ -676,42 +710,6 @@ run_continual_mode(const struct location_provider *provider, int main(int argc, char *argv[]) { - /* List of gamma methods. */ - const struct gamma_method gamma_methods[] = { -#ifdef ENABLE_COOPGAMMA - coopgamma_gamma_method, -#endif -#ifdef ENABLE_DRM - drm_gamma_method, -#endif -#ifdef ENABLE_RANDR - randr_gamma_method, -#endif -#ifdef ENABLE_VIDMODE - vidmode_gamma_method, -#endif -#ifdef ENABLE_QUARTZ - quartz_gamma_method, -#endif -#ifdef ENABLE_WINGDI - w32gdi_gamma_method, -#endif - dummy_gamma_method, - { NULL } - }; - - /* List of location providers. */ - const struct location_provider location_providers[] = { -#ifdef ENABLE_GEOCLUE2 - geoclue2_location_provider, -#endif -#ifdef ENABLE_CORELOCATION - corelocation_location_provider, -#endif - manual_location_provider, - { NULL } - }; - struct options options; struct config_ini_state config_state; struct transition_scheme *scheme; @@ -734,14 +732,14 @@ main(int argc, char *argv[]) #endif options_init(&options); - options_parse_args(&options, argc, argv, gamma_methods, location_providers); + options_parse_args(&options, argc, argv); /* Load settings from config file. */ config_ini_init(&config_state, options.config_filepath); free(options.config_filepath); - options_parse_config_file(&options, &config_state, gamma_methods, location_providers); + options_parse_config_file(&options, &config_state); options_set_defaults(&options); @@ -770,11 +768,11 @@ main(int argc, char *argv[]) if (options.provider) { /* Use provider specified on command line. */ if (provider_try_start(options.provider, &location_state, &config_state, options.provider_args) < 0) - exit(EXIT_FAILURE); + exit(1); } else { /* Try all providers, use the first that works. */ - for (i = 0; location_providers[i].name != NULL; i++) { - const struct location_provider *p = &location_providers[i]; + for (i = 0; location_providers[i]; i++) { + const struct location_provider *p = location_providers[i]; weprintf(_("Trying location provider `%s'..."), p->name); if (provider_try_start(p, &location_state, &config_state, NULL) < 0) { weprintf(_("Trying next provider...")); @@ -865,11 +863,11 @@ main(int argc, char *argv[]) r = method_try_start(options.method, &method_state, options.mode, &config_state, options.method_args); if (r < 0) - exit(EXIT_FAILURE); + exit(1); } else { /* Try all methods, use the first that works. */ - for (i = 0; gamma_methods[i].name; i++) { - const struct gamma_method *m = &gamma_methods[i]; + for (i = 0; gamma_methods[i]; i++) { + const struct gamma_method *m = gamma_methods[i]; if (!m->autostart) continue; |