diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-22 10:04:16 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-22 10:04:16 +0100 |
commit | edd04f4d9916f8348993da1346561bbf550c05f0 (patch) | |
tree | ab3ade71d2b96ac205ca373113066b89a4a52a14 /src/config.c | |
parent | Unlist redshift/issues/721 (diff) | |
download | redshift-ng-edd04f4d9916f8348993da1346561bbf550c05f0.tar.gz redshift-ng-edd04f4d9916f8348993da1346561bbf550c05f0.tar.bz2 redshift-ng-edd04f4d9916f8348993da1346561bbf550c05f0.tar.xz |
minor fixes + add option to start in disabled mode
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/src/config.c b/src/config.c index ed61486..bb6f1d5 100644 --- a/src/config.c +++ b/src/config.c @@ -27,9 +27,11 @@ static void usage(void) { fprintf(stderr, _("usage: %s %s\n"), argv0, - _("[-b brightness] [-c file] [-g gamma] [-l latitude:longitude | -l provider[:options]] " - "[-m method[:options]] [-O temperature | -o | -p | -t temperature | -x] [-P | +P] " - "[-r | +r] [-dv] | -h | -V")); + _("[-b brightness] [-c file] [-D | +D] [-g gamma] " + "[-l latitude:longitude | -l provider[:options]] " + "[-m method[:options]] [-P | +P] [-r | +r] [-dv]" + "[-O temperature | -o | -p | -t temperature | -x] " + "| -h | -V")); exit(1); } @@ -656,6 +658,11 @@ load_from_cmdline(struct settings *settings, int argc, char *argv[]) settings->config_file = ARG(); break; + case 'D': + settings->disabled.source |= SETTING_CMDLINE; + settings->disabled.value = 0; + break; + case 'd': settings->until_death = 1; break; @@ -734,17 +741,13 @@ load_from_cmdline(struct settings *settings, int argc, char *argv[]) } break; - case 'o': - mode = PROGRAM_MODE_ONE_SHOT; - break; - case 'O': mode = PROGRAM_MODE_ONE_SHOT; set_temperature(ARG(), &settings->day.temperature, &settings->night.temperature, NULL); break; - case 'p': - mode = PROGRAM_MODE_PRINT; + case 'o': + mode = PROGRAM_MODE_ONE_SHOT; break; case 'P': @@ -752,6 +755,10 @@ load_from_cmdline(struct settings *settings, int argc, char *argv[]) settings->preserve_gamma.value = 0; break; + case 'p': + mode = PROGRAM_MODE_PRINT; + break; + case 'r': settings->use_fade.source |= SETTING_CMDLINE; settings->use_fade.value = 0; @@ -761,14 +768,14 @@ load_from_cmdline(struct settings *settings, int argc, char *argv[]) set_temperature(ARG(), &settings->day.temperature, &settings->night.temperature, NULL); break; - case 'v': - verbose = 1; - break; - case 'V': printf("%s\n", VERSION_STRING); exit(0); + case 'v': + verbose = 1; + break; + case 'x': mode = PROGRAM_MODE_RESET; break; @@ -777,6 +784,11 @@ load_from_cmdline(struct settings *settings, int argc, char *argv[]) usage(); } ARGALT('+') { + case 'D': + settings->disabled.source |= SETTING_CMDLINE; + settings->disabled.value = 1; + break; + case 'P': settings->preserve_gamma.source |= SETTING_CMDLINE; settings->preserve_gamma.value = 1; @@ -845,6 +857,13 @@ load_from_config_ini(struct settings *settings, const char *key, char *value) if (settings->preserve_gamma.source <= SETTING_CONFIGFILE) settings->preserve_gamma.value = get_boolean(value, key); + } else if (!strcasecmp(key, "start-disabled")) { + if (settings->disabled.source & SETTING_CONFIGFILE) + weprintf(_("`start-disabled' setting specified multiple times in configuration file.")); + settings->disabled.source |= SETTING_CONFIGFILE; + if (settings->disabled.source <= SETTING_CONFIGFILE) + settings->disabled.value = get_boolean(value, key); + } else if (!strcasecmp(key, "elevation-high")) { if (settings->elevation_high.source & SETTING_CONFIGFILE) weprintf(_("`elevation-high' setting specified multiple times in configuration file.")); @@ -945,6 +964,7 @@ load_settings(struct settings *settings, int argc, char *argv[]) mode = PROGRAM_MODE_UNTIL_DEATH; preserve_gamma = settings->preserve_gamma.value; use_fade = settings->use_fade.value; + disable ^= settings->disabled.value; day_settings.temperature = settings->day.temperature.value; day_settings.brightness = settings->day.brightness.value; day_settings.gamma[0] = settings->day.gamma.value[0]; @@ -991,13 +1011,13 @@ settings_published: /* TRANSLATORS: Append degree symbols if possible. */ printf(_("Solar elevations: day above %.1f, night below %.1f\n"), scheme.elevation.high, scheme.elevation.low); - } else if (scheme.type == CLOCK_SCHEME) {/ + } else if (scheme.type == CLOCK_SCHEME) { printf(_("Schedule:\n")); current = first = scheme.time.periods; do { printf(_(" %.2f%% day at %02u:%02u:%02u\n"), - current->day_level * 100, current->start / 60 / 60 % 24, - current->start / 60 % 60, current->start % 60); + current->day_level * 100, (unsigned)(current->start / 60 / 60 % 24), + (unsigned)(current->start / 60 % 60), (unsigned)(current->start % 60)); } while ((current = current->next) != first); printf(_("(End of schedule)\n")); } |