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
1=== modified file 'redshift.1'
2--- redshift.1 2011-10-18 17:49:20 +0000
3+++ redshift.1 2011-11-27 17:56:25 +0000
4@@ -60,6 +60,9 @@
5 \fB\-O\fR TEMP
6 One shot manual mode (set color temperature)
7 .TP
8+\fB\-p\fR
9+Print mode (only print parameters and exit)
10+.TP
11 \fB\-x\fR
12 Reset mode (remove adjustment from screen)
13 .TP
14
15=== modified file 'src/redshift.c'
16--- src/redshift.c 2011-10-18 16:02:28 +0000
17+++ src/redshift.c 2011-11-27 17:56:25 +0000
18@@ -226,6 +226,7 @@
19 typedef enum {
20 PROGRAM_MODE_CONTINUAL,
21 PROGRAM_MODE_ONE_SHOT,
22+ PROGRAM_MODE_PRINT,
23 PROGRAM_MODE_RESET,
24 PROGRAM_MODE_MANUAL
25 } program_mode_t;
26@@ -333,6 +334,7 @@
27 " -o\t\tOne shot mode (do not continously adjust"
28 " color temperature)\n"
29 " -O TEMP\tOne shot manual mode (set color temperature)\n"
30+ " -p\t\tPrint mode (only print parameters and exit)"
31 " -x\t\tReset mode (remove adjustment from screen)\n"
32 " -r\t\tDisable temperature transitions\n"
33 " -t DAY:NIGHT\tColor temperature to set at daytime/night\n"),
34@@ -666,7 +668,7 @@
35
36 /* Parse command line arguments. */
37 int opt;
38- while ((opt = getopt(argc, argv, "b:c:g:hl:m:oO:rt:vVx")) != -1) {
39+ while ((opt = getopt(argc, argv, "b:c:g:hl:m:oO:prt:vVx")) != -1) {
40 switch (opt) {
41 case 'b':
42 parse_brightness_string(optarg, &brightness_day, &brightness_night);
43@@ -771,6 +773,9 @@
44 mode = PROGRAM_MODE_MANUAL;
45 temp_set = atoi(optarg);
46 break;
47+ case 'p':
48+ mode = PROGRAM_MODE_PRINT;
49+ break;
50 case 'r':
51 transition = 0;
52 break;
53@@ -1082,6 +1087,7 @@
54
55 switch (mode) {
56 case PROGRAM_MODE_ONE_SHOT:
57+ case PROGRAM_MODE_PRINT:
58 {
59 /* Current angular elevation of the sun */
60 double now;
61@@ -1105,11 +1111,14 @@
62 float brightness = calculate_interpolated_value(elevation,
63 brightness_day, brightness_night);
64
65- if (verbose) {
66+ if (verbose || mode == PROGRAM_MODE_PRINT) {
67 print_period(elevation);
68 printf(_("Color temperature: %uK\n"), temp);
69 printf(_("Brightness: %.2f\n"), brightness);
70 }
71+ if(mode == PROGRAM_MODE_PRINT) {
72+ exit(EXIT_SUCCESS);
73+ }
74
75 /* Adjust temperature */
76 r = method->set_temperature(&state, temp, brightness, gamma);

Subscribers

People subscribed via source and target branches

to all changes: