aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/config.c b/src/config.c
index 443991d..1613770 100644
--- a/src/config.c
+++ b/src/config.c
@@ -26,7 +26,9 @@ USAGE("[-b day:night] [-c file] [-g r:g:b] [-l latitude:longitude | -l provider[
struct colour_setting day_settings;
struct colour_setting night_settings;
-union scheme scheme;
+union scheme scheme = {.type = SOLAR_SCHEME};
+enum program_mode mode = PROGRAM_MODE_CONTINUAL;
+int verbose = 0;
/**
@@ -569,9 +571,6 @@ load_defaults(struct settings *settings)
settings->provider = NULL;
settings->provider_args = NULL;
-
- settings->mode = PROGRAM_MODE_CONTINUAL;
- settings->scheme_type = SOLAR_SCHEME;
}
@@ -673,16 +672,16 @@ load_from_cmdline(struct settings *settings, int argc, char *argv[])
break;
case 'o':
- settings->mode = PROGRAM_MODE_ONE_SHOT;
+ mode = PROGRAM_MODE_ONE_SHOT;
break;
case 'O':
- settings->mode = PROGRAM_MODE_MANUAL;
+ mode = PROGRAM_MODE_ONE_SHOT;
set_temperature(ARG(), &settings->day.temperature, &settings->night.temperature, NULL);
break;
case 'p':
- settings->mode = PROGRAM_MODE_PRINT;
+ mode = PROGRAM_MODE_PRINT;
break;
case 'P':
@@ -700,7 +699,7 @@ load_from_cmdline(struct settings *settings, int argc, char *argv[])
break;
case 'v':
- settings->verbose = 1;
+ verbose = 1;
break;
case 'V':
@@ -709,7 +708,7 @@ load_from_cmdline(struct settings *settings, int argc, char *argv[])
break;
case 'x':
- settings->mode = PROGRAM_MODE_RESET;
+ mode = PROGRAM_MODE_RESET;
break;
default:
@@ -828,7 +827,7 @@ load_settings(struct settings *settings, int argc, char *argv[])
n = !settings->dawn.start.source + !settings->dawn.end.source;
n += !settings->dusk.start.source + !settings->dusk.end.source;
if (n) {
- settings->scheme_type = CLOCK_SCHEME;
+ scheme.type = CLOCK_SCHEME;
if (n != 4)
eprintf(_("Partial time-configuration not supported!"));
@@ -858,19 +857,26 @@ load_settings(struct settings *settings, int argc, char *argv[])
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
- if (settings->mode == PROGRAM_MODE_RESET) {
- settings->scheme_type = STATIC_SCHEME;
- } else if (settings->day.temperature.value == settings->night.temperature.value &&
- settings->day.brightness.value == settings->night.brightness.value &&
- settings->day.gamma.value[0] == settings->night.gamma.value[0] &&
- settings->day.gamma.value[1] == settings->night.gamma.value[1] &&
- settings->day.gamma.value[2] == settings->night.gamma.value[2]) {
- settings->scheme_type = STATIC_SCHEME;
+ if (settings->day.temperature.value == settings->night.temperature.value &&
+ settings->day.brightness.value == settings->night.brightness.value &&
+ settings->day.gamma.value[0] == settings->night.gamma.value[0] &&
+ settings->day.gamma.value[1] == settings->night.gamma.value[1] &&
+ settings->day.gamma.value[2] == settings->night.gamma.value[2]) {
+ scheme.type = STATIC_SCHEME;
}
#if defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
+ /* If reseting effects, use neutral colour settings (static scheme) and do not preserve gamma */
+ if (mode == PROGRAM_MODE_RESET) {
+ scheme.type = STATIC_SCHEME;
+ settings->preserve_gamma.value = 0;
+ day_settings = COLOUR_SETTING_NEUTRAL;
+ night_settings = COLOUR_SETTING_NEUTRAL;
+ goto settings_published;
+ }
+
/* Publish loaded settings */
day_settings.temperature = settings->day.temperature.value;
day_settings.brightness = settings->day.brightness.value;
@@ -882,7 +888,6 @@ load_settings(struct settings *settings, int argc, char *argv[])
night_settings.gamma[0] = settings->night.gamma.value[0];
night_settings.gamma[1] = settings->night.gamma.value[1];
night_settings.gamma[2] = settings->night.gamma.value[2];
- scheme.type = settings->scheme_type;
if (scheme.type == SOLAR_SCHEME) {
scheme.elevation.high = settings->elevation_high.value;
scheme.elevation.low = settings->elevation_low.value;
@@ -908,9 +913,10 @@ load_settings(struct settings *settings, int argc, char *argv[])
scheme.time.periods_array[i].diff_over_duration /= duration ? (double)duration : 1.0;
}
}
+settings_published:
/* Output settings */
- if (settings->verbose) {
+ if (verbose) {
if (scheme.type == SOLAR_SCHEME) {
/* TRANSLATORS: Append degree symbols if possible. */
printf(_("Solar elevations: day above %.1f, night below %.1f\n"),