Page 1 of 1

Capturing xgamma command output

Posted: Tue Sep 14, 2021 10:47 pm
by greengeek

I am using the xgamma command to interrogate and if necessary adjust r,g or b gamma values. (On tahr32 6.0.6)

xgamma --help says "If no gamma is specified, returns the current setting"

Using xgamma command on its own returns the following:

Code: Select all

root# xgamma
-> Red  1.000, Green  1.000, Blue  1.000

In order to extract these values for later use in a script I tried the following:

Code: Select all

root# xgamma > /root/output.txt
-> Red  1.000, Green  1.000, Blue  1.000
root#

But there is no data put into the output.txt file.

Can anyone help me to understand what I am doing wrong please?

Cheers!


Re: Capturing xgamma command output

Posted: Tue Sep 14, 2021 11:55 pm
by williams2

The output from xgamma is to STDERR not to STDOUT.

This should work:

xgamma 2> /root/output.txt

Other ways of doing similar things:

xgamma 2>&1 | awk '{print $3 $5 $7}'

xgamma 2>&1 | awk '{print $3 $5 $7}' > /root/output.txt

xgamma 2>&1 | awk '{print $3 $5 $7}' | tr "," " "

xgamma 2>&1 | awk '{print $3 $5 $7}' | tr "," " " > /root/output.txt


Re: Capturing xgamma command output

Posted: Wed Sep 15, 2021 12:10 am
by PipzDex

Hello there
Maybe this pet can help you understand how gamma works

I know, you are using XGAMMA but it seems that you are trying to modify the tint of the monitor and this program has that option using XRANDR ...

This is the output

Code: Select all

#!/bin/sh
	LC_NUMERIC=C xrandr --output VGA1 --gamma 1.00000000:0.98883326:0.97779486 --brightness 1.30

install it and make the desired modification and the resulting file will be saved in root / startup
there you can see the result

NOTE: this pet is a test extract, the full program is inside in the new JWMDesk 3.1 from Radky


Re: Capturing xgamma command output

Posted: Wed Sep 15, 2021 12:25 am
by greengeek
PipzDex wrote: Wed Sep 15, 2021 12:10 am

I know, you are using XGAMMA but it seems that you are trying to modify the tint of the monitor and this program has that option using XRANDR ...

Thanks PipzDex -I usually use xrandr for screen adjustments but in this case I wanted to work with the simpler format of the data output from xgamma. (Trying to use grep/sed/awk to obtain individual r:g:b values and they looked more clearly laid out in the xamma output rather than the xrandr output)
Cheers!


Re: Capturing xgamma command output

Posted: Wed Sep 15, 2021 12:30 am
by greengeek
williams2 wrote: Tue Sep 14, 2021 11:55 pm

The output from xgamma is to STDERR not to STDOUT.

This should work:
xgamma 2> /root/output.txt

Other ways of doing similar things:
xgamma 2>&1 | awk '{print $3 $5 $7}'
xgamma 2>&1 | awk '{print $3 $5 $7}' > /root/output.txt
xgamma 2>&1 | awk '{print $3 $5 $7}' | tr "," " "
xgamma 2>&1 | awk '{print $3 $5 $7}' | tr "," " " > /root/output.txt

Thanks for the explanation. These examples get me well on my way.
(Can I ask how you know that the output is to STDERR? Is that something to do with compile time options or is there some indication in the program output?)
Many thanks!


Re: Capturing xgamma command output

Posted: Wed Sep 15, 2021 2:37 am
by williams2

how you know that the output is to STDERR?

I suspected the output was to STDERR, because I've had similar problems before.

Fastest way to test the output:

this will show no output if output is to STDOUT:
xgamma > /dev/null

this will show no output if output is to STDERR:
xgamma 2> /dev/null

Whether output is to STDOUT or is to STDERR was chosen by the programmer who wrote the program source.
The programmer who wrote the source of the program, can include compile time options, or not.

The man page (manual) might tell you whether the output is to STDERR, but it might not.
And the documentation can be wrong. Better to test it yourself.


Re: Capturing xgamma command output

Posted: Wed Sep 15, 2021 4:24 am
by greengeek
williams2 wrote: Wed Sep 15, 2021 2:37 am

Fastest way to test the output:
this will show no output if output is to STDOUT:
xgamma > /dev/null
this will show no output if output is to STDERR:
xgamma 2> /dev/null

Thanks - useful test:

Code: Select all

root# xgamma > /dev/null
-> Red  0.700, Green  0.700, Blue  0.700
root# xgamma 2> /dev/null
root#