Merge lp:~valodim/redshift/printmode into lp:~jonls/redshift/trunk

Proposed by Valodim
Status: Merged
Merged at revision: 172
Proposed branch: lp:~valodim/redshift/printmode
Merge into: lp:~jonls/redshift/trunk
Diff against target: 76 lines (+14/-2)
2 files modified
redshift.1 (+3/-0)
src/redshift.c (+11/-2)
To merge this branch: bzr merge lp:~valodim/redshift/printmode
Reviewer Review Type Date Requested Status
Jon Lund Steffensen Approve
Review via email: mp+83520@code.launchpad.net

Description of the change

Mostly trivial change, adding an option -p to simply print the Solr Elevation and Color Temperature parameters for the current time and location, then exit.

This can be useful for a simple scripted lookup, e.g. for use in status bar scripts. I use it from within conky with ${execi}.

To post a comment you must log in.
Revision history for this message
Jon Lund Steffensen (jonls) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'redshift.1'
--- redshift.1 2011-10-18 17:49:20 +0000
+++ redshift.1 2011-11-27 17:56:25 +0000
@@ -60,6 +60,9 @@
60\fB\-O\fR TEMP60\fB\-O\fR TEMP
61One shot manual mode (set color temperature)61One shot manual mode (set color temperature)
62.TP62.TP
63\fB\-p\fR
64Print mode (only print parameters and exit)
65.TP
63\fB\-x\fR66\fB\-x\fR
64Reset mode (remove adjustment from screen)67Reset mode (remove adjustment from screen)
65.TP68.TP
6669
=== modified file 'src/redshift.c'
--- src/redshift.c 2011-10-18 16:02:28 +0000
+++ src/redshift.c 2011-11-27 17:56:25 +0000
@@ -226,6 +226,7 @@
226typedef enum {226typedef enum {
227 PROGRAM_MODE_CONTINUAL,227 PROGRAM_MODE_CONTINUAL,
228 PROGRAM_MODE_ONE_SHOT,228 PROGRAM_MODE_ONE_SHOT,
229 PROGRAM_MODE_PRINT,
229 PROGRAM_MODE_RESET,230 PROGRAM_MODE_RESET,
230 PROGRAM_MODE_MANUAL231 PROGRAM_MODE_MANUAL
231} program_mode_t;232} program_mode_t;
@@ -333,6 +334,7 @@
333 " -o\t\tOne shot mode (do not continously adjust"334 " -o\t\tOne shot mode (do not continously adjust"
334 " color temperature)\n"335 " color temperature)\n"
335 " -O TEMP\tOne shot manual mode (set color temperature)\n"336 " -O TEMP\tOne shot manual mode (set color temperature)\n"
337 " -p\t\tPrint mode (only print parameters and exit)"
336 " -x\t\tReset mode (remove adjustment from screen)\n"338 " -x\t\tReset mode (remove adjustment from screen)\n"
337 " -r\t\tDisable temperature transitions\n"339 " -r\t\tDisable temperature transitions\n"
338 " -t DAY:NIGHT\tColor temperature to set at daytime/night\n"),340 " -t DAY:NIGHT\tColor temperature to set at daytime/night\n"),
@@ -666,7 +668,7 @@
666 668
667 /* Parse command line arguments. */669 /* Parse command line arguments. */
668 int opt;670 int opt;
669 while ((opt = getopt(argc, argv, "b:c:g:hl:m:oO:rt:vVx")) != -1) {671 while ((opt = getopt(argc, argv, "b:c:g:hl:m:oO:prt:vVx")) != -1) {
670 switch (opt) {672 switch (opt) {
671 case 'b':673 case 'b':
672 parse_brightness_string(optarg, &brightness_day, &brightness_night);674 parse_brightness_string(optarg, &brightness_day, &brightness_night);
@@ -771,6 +773,9 @@
771 mode = PROGRAM_MODE_MANUAL;773 mode = PROGRAM_MODE_MANUAL;
772 temp_set = atoi(optarg);774 temp_set = atoi(optarg);
773 break;775 break;
776 case 'p':
777 mode = PROGRAM_MODE_PRINT;
778 break;
774 case 'r':779 case 'r':
775 transition = 0;780 transition = 0;
776 break;781 break;
@@ -1082,6 +1087,7 @@
10821087
1083 switch (mode) {1088 switch (mode) {
1084 case PROGRAM_MODE_ONE_SHOT:1089 case PROGRAM_MODE_ONE_SHOT:
1090 case PROGRAM_MODE_PRINT:
1085 {1091 {
1086 /* Current angular elevation of the sun */1092 /* Current angular elevation of the sun */
1087 double now;1093 double now;
@@ -1105,11 +1111,14 @@
1105 float brightness = calculate_interpolated_value(elevation,1111 float brightness = calculate_interpolated_value(elevation,
1106 brightness_day, brightness_night);1112 brightness_day, brightness_night);
11071113
1108 if (verbose) {1114 if (verbose || mode == PROGRAM_MODE_PRINT) {
1109 print_period(elevation);1115 print_period(elevation);
1110 printf(_("Color temperature: %uK\n"), temp);1116 printf(_("Color temperature: %uK\n"), temp);
1111 printf(_("Brightness: %.2f\n"), brightness);1117 printf(_("Brightness: %.2f\n"), brightness);
1112 }1118 }
1119 if(mode == PROGRAM_MODE_PRINT) {
1120 exit(EXIT_SUCCESS);
1121 }
11131122
1114 /* Adjust temperature */1123 /* Adjust temperature */
1115 r = method->set_temperature(&state, temp, brightness, gamma);1124 r = method->set_temperature(&state, temp, brightness, gamma);

Subscribers

People subscribed via source and target branches

to all changes: