diff -ur redshift-1.3/src/redshift.c redshift-1.3_reset/src/redshift.c --- redshift-1.3/src/redshift.c 2010-05-06 15:29:54.000000000 -0700 +++ redshift-1.3_reset/src/redshift.c 2010-06-08 21:14:23.000000000 -0700 @@ -103,6 +103,7 @@ #define DEFAULT_DAY_TEMP 5500 #define DEFAULT_NIGHT_TEMP 3700 #define DEFAULT_GAMMA 1.0 +#define RESET_TEMP 6500 /* Angular elevation of the sun at which the color temperature transition period starts and ends (in degress). @@ -276,7 +277,8 @@ " -r\t\tDisable temperature transitions\n" " -s SCREEN\tX screen to apply adjustments to\n" " -c CRTC\tCRTC to apply adjustments to (RANDR only)\n" - " -t DAY:NIGHT\tColor temperature to set at daytime/night\n"), + " -t DAY:NIGHT\tColor temperature to set at daytime/night\n" + " -x\t\tReset color temperature to default (same as -o -t 6500:6500)\n"), stdout); fputs("\n", stdout); @@ -320,11 +322,12 @@ int transition = 1; int one_shot = 0; int verbose = 0; + int reset = 0; char *s; /* Parse arguments. */ int opt; - while ((opt = getopt(argc, argv, "c:g:hl:m:ors:t:v")) != -1) { + while ((opt = getopt(argc, argv, "c:g:hl:m:ors:t:v:x")) != -1) { switch (opt) { case 'c': crtc_num = atoi(optarg); @@ -435,6 +438,9 @@ case 'v': verbose = 1; break; + case 'x': + reset = 1; + break; case '?': fputs(_("Try `-h' for more information.\n"), stderr); exit(EXIT_FAILURE); @@ -443,7 +449,7 @@ } /* Latitude and longitude must be set */ - if (isnan(lat) || isnan(lon)) { + if (!reset && (isnan(lat) || isnan(lon))) { fputs(_("Latitude and longitude must be set.\n"), stderr); fputs(_("Try `-h' for more information.\n"), stderr); exit(EXIT_FAILURE); @@ -455,7 +461,7 @@ } /* Latitude */ - if (lat < MIN_LAT || lat > MAX_LAT) { + if (!reset && (lat < MIN_LAT || lat > MAX_LAT)) { /* TRANSLATORS: Append degree symbols if possible. */ fprintf(stderr, _("Latitude must be between %.1f and %.1f.\n"), @@ -464,7 +470,7 @@ } /* Longitude */ - if (lon < MIN_LON || lon > MAX_LON) { + if (!reset && (lon < MIN_LON || lon > MAX_LON)) { /* TRANSLATORS: Append degree symbols if possible. */ fprintf(stderr, _("Longitude must be between %.1f and %.1f.\n"), @@ -602,6 +608,18 @@ gamma_state_free(&state, method); exit(EXIT_FAILURE); } + } else if (reset) { + int temp = RESET_TEMP; + + if (verbose) printf(_("Color temperature: %uK\n"), temp); + + /* Adjust temperature */ + r = gamma_state_set_temperature(&state, method, temp, gamma); + if (r < 0) { + fputs(_("Temperature adjustment failed.\n"), stderr); + gamma_state_free(&state, method); + exit(EXIT_FAILURE); + } } else { /* Transition state */ double short_trans_end = 0;