summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2018-02-05 01:31:15 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2018-02-27 12:18:07 +0100
commitcf25d585df5582d29528acc35f1c91dcb98b0f00 (patch)
tree307a7d4d5206c027683dc933da7fbcff5a7b8695
parent289bc0f1c53d8bc488d96e7f79afabd361758e08 (diff)
xrandr: allow single value for --gamma
Similarly to --scale, accept a single value to be used for all three components, and refuse values with extra junk after the acceptable values. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r--man/xrandr.man9
-rw-r--r--xrandr.c15
2 files changed, 17 insertions, 7 deletions
diff --git a/man/xrandr.man b/man/xrandr.man
index cfbfb8f..9f976ad 100644
--- a/man/xrandr.man
+++ b/man/xrandr.man
@@ -63,7 +63,7 @@ xrandr \- primitive command line interface to RandR extension
[\-\-set \fIproperty\fP \fIvalue\fP]
[\-\-off]
[\-\-crtc \fIcrtc\fP]
-[\-\-gamma \fIred\fP:\fIgreen\fP:\fIblue\fP]
+[\-\-gamma \fIred\fP[:\fIgreen\fP:\fIblue\fP]]
[\-\-brightness \fIbrightness\fP]
[\-o \fIorientation\fP]
[\-s \fIsize\fP]
@@ -303,9 +303,12 @@ Uses the specified crtc (either as an index in the list of CRTCs or XID).
In normal usage, this option is not required as xrandr tries to make
sensible choices about which crtc to use with each output. When that fails
for some reason, this option can override the normal selection.
-.IP "\-\-gamma \fIred\fP:\fIgreen\fP:\fIblue\fP"
+.IP "\-\-gamma \fIred\fP[:\fIgreen\fP:\fIblue\fP]"
Set the specified floating point values as gamma correction on the crtc
-currently attached to this output. Note that you cannot get two different values
+currently attached to this output.
+If green and blue are not specified, the red value will be used
+for all three components.
+Note that you cannot get two different values
for cloned outputs (i.e.: which share the same crtc) and that switching an output to another crtc doesn't change
the crtc gamma corrections at all.
.IP "\-\-brightness \fIbrightness\fP"
diff --git a/xrandr.c b/xrandr.c
index 6a38cf2..f6c425f 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -144,7 +144,7 @@ usage(void)
" --off\n"
" --crtc <crtc>\n"
" --panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]\n"
- " --gamma <r>:<g>:<b>\n"
+ " --gamma <r>[:<g>:<b>]\n"
" --brightness <value>\n"
" --primary\n"
" --noprimary\n"
@@ -2967,11 +2967,18 @@ main (int argc, char **argv)
continue;
}
if (!strcmp ("--gamma", argv[i])) {
+ char junk;
if (!config_output) argerr ("%s must be used after --output\n", argv[i]);
if (++i >= argc) argerr ("%s requires an argument\n", argv[i-1]);
- if (sscanf(argv[i], "%f:%f:%f", &config_output->gamma.red,
- &config_output->gamma.green, &config_output->gamma.blue) != 3)
- argerr ("%s: invalid argument '%s'\n", argv[i-1], argv[i]);
+ if (sscanf(argv[i], "%f:%f:%f%c", &config_output->gamma.red,
+ &config_output->gamma.green, &config_output->gamma.blue, &junk) != 3)
+ {
+ /* check if it's a single floating-point value,
+ * to be applied to all components */
+ if (sscanf(argv[i], "%f%c", &config_output->gamma.red, &junk) != 1)
+ argerr ("%s: invalid argument '%s'\n", argv[i-1], argv[i]);
+ config_output->gamma.green = config_output->gamma.blue = config_output->gamma.red;
+ }
config_output->changes |= changes_gamma;
setit_1_2 = True;
continue;