sct

set color temperature
git clone anongit@rnpnr.xyz:sct.git
Log | Files | Refs | Feed | README | LICENSE

Commit: cabdd92f8a82e50f63e2ca6bd65b5cc3c6309037
Parent: 60aff70e6809d093530b67476501d46028d5f6ca
Author: Randy Palamar
Date:   Sun,  2 Apr 2023 23:03:14 -0600

change '-d' usage to something more sensible

Diffstat:
Msct.1 | 4++--
Msct.c | 21+++++++++++----------
2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/sct.1 b/sct.1 @@ -16,8 +16,8 @@ sets the screen's color temperature. .B -v verbose output. .TP -.B -d -Shift temperature by temperature value +.B -d dT +shift temperature by dT. .TP .B -s N Zero-based index of screen to use. diff --git a/sct.c b/sct.c @@ -56,7 +56,7 @@ die(const char *errstr, ...) static void usage(void) { - die("usage: %s [-vd] [-c CRTC] [-s screen] [temperature] " + die("usage: %s [-v] [-d dT] [-c CRTC] [-s screen] [temperature] " "[brightness]\n", argv0); } @@ -202,13 +202,15 @@ main(int argc, char **argv) int screen_specified = -1, screen_first = 0, screen_last = -1; int crtc_specified = -1; struct temp_status temp = { .temp = DELTA_MIN, .brightness = -1.0 }; - int dflag = 0; + int delta = 0; argv0 = argv[0]; ARGBEGIN { case 'd': - dflag = 1; + delta = atoi(EARGF(usage())); + if (delta == 0) + usage(); break; case 'v': vflag = 1; @@ -251,7 +253,7 @@ main(int argc, char **argv) screen_first = screen_specified; screen_last = screen_specified; } - if ((temp.temp < 0) && !dflag) { + if (temp.temp < 0 && delta == 0) { // No arguments, so print estimated temperature for each // screen for (screen = screen_first; screen <= screen_last; screen++) { @@ -260,15 +262,14 @@ main(int argc, char **argv) temp.temp, temp.brightness); } } else { - struct temp_status tempd = {.temp = 0, .brightness = 1.0}; - if (!dflag && temp.temp == 0) + if (delta == 0 && temp.temp == 0) temp.temp = TEMPERATURE_NORM; for (screen = screen_first; screen <= screen_last; screen++) { - if (dflag) { - get_sct_for_screen(&tempd, screen, crtc_specified); - tempd.temp += temp.temp; + if (delta) { + get_sct_for_screen(&temp, screen, crtc_specified); + temp.temp += delta; } - sct_for_screen(screen, crtc_specified, dflag? &tempd : &temp); + sct_for_screen(screen, crtc_specified, &temp); } }