diff options
| author | Jon Lund Steffensen <jonlst@gmail.com> | 2014-12-27 21:01:23 -0500 | 
|---|---|---|
| committer | Jon Lund Steffensen <jonlst@gmail.com> | 2014-12-27 21:26:37 -0500 | 
| commit | 431780b851fe7eac9c00ffb29ed5f1eaf02ec565 (patch) | |
| tree | 8889de13d27eeda4ef3bbab7157757bcc736d9a9 /src/redshift.c | |
| parent | redshift: Change duration of sleep to macro (diff) | |
| download | redshift-ng-431780b851fe7eac9c00ffb29ed5f1eaf02ec565.tar.gz redshift-ng-431780b851fe7eac9c00ffb29ed5f1eaf02ec565.tar.bz2 redshift-ng-431780b851fe7eac9c00ffb29ed5f1eaf02ec565.tar.xz | |
redshift: Be less verbose when color values did not change
This keeps a copy of the previous color_setting_t in the loop so
that we can avoid printing the color temperature and brightness if
they did not change.
Diffstat (limited to 'src/redshift.c')
| -rw-r--r-- | src/redshift.c | 22 | 
1 files changed, 20 insertions, 2 deletions
| diff --git a/src/redshift.c b/src/redshift.c index 1c8723c..00bf9f9 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -1370,6 +1370,12 @@ main(int argc, char *argv[])  			printf("Status: %s\n", "Enabled");  		} +		/* Save previous colors so we can avoid +		   printing status updates if the values +		   did not change. */ +		color_setting_t prev_interp = +			{ -1, { NAN, NAN, NAN }, NAN }; +  		/* Continuously adjust color temperature */  		int done = 0;  		int disabled = 0; @@ -1471,8 +1477,16 @@ main(int argc, char *argv[])  			if (done && !short_trans_delta) break;  			if (verbose) { -				printf(_("Color temperature: %uK\n"), interp.temperature); -				printf(_("Brightness: %.2f\n"), interp.brightness); +				if (interp.temperature != +				    prev_interp.temperature) { +					printf(_("Color temperature: %uK\n"), +					       interp.temperature); +				} +				if (interp.brightness != +				    prev_interp.brightness) { +					printf(_("Brightness: %.2f\n"), +					       interp.brightness); +				}  			}  			/* Adjust temperature */ @@ -1486,6 +1500,10 @@ main(int argc, char *argv[])  				}  			} +			/* Save temperature as previous */ +			memcpy(&prev_interp, &interp, +			       sizeof(color_setting_t)); +  			/* Sleep for 5 seconds or 0.1 second. */  #ifndef _WIN32  			if (short_trans_delta) usleep(SLEEP_DURATION_SHORT*1000); | 
