xgamma -display parameter for dual monitor setup

I want to change gamma for my first monitor. Every time I invoke xgamma with different -display parameters it somehow points to my second monitor. But I want to modify first one.

I tried these commands.

The parameters I have used for -display are :0, :0.0, :0.1, :1.0, :1.1, :1. Only the first 2 works. But it points to my second monitor. Not the first one. Here is a shell script to test it.

shiplu@KubuntuD:~$ xgamma -display :0
-> Red  1.000, Green  1.000, Blue  1.000
shiplu@KubuntuD:~$ xgamma -display :0.0
-> Red  1.000, Green  1.000, Blue  1.000
shiplu@KubuntuD:~$ xgamma -display :0.1
xgamma:  unable to open display ':0.1'
shiplu@KubuntuD:~$ xgamma -display :1.0
xgamma:  unable to open display ':1.0'
shiplu@KubuntuD:~$ xgamma -display :1.1
xgamma:  unable to open display ':1.1'
shiplu@KubuntuD:~$ xgamma -display :1
xgamma:  unable to open display ':1'

How can I change the gamma for the first/primary monitor?


Solution 1:

I have same problem with xgamma, you can use xrandr to do that

my first monitor:

xrandr --output VGA1 --mode 1360x768 --pos 0x0 --rotate normal --gamma 1.000:1.000:1.000

my second monitor:

xrandr --output LVDS1 --mode 1024x600 --pos 0x768 --rotate normal --gamma 1.100:1.000:1.000

the --gamma parameter works in same way that xgamma

--gamma R:G:B 
xrandr --output (some monitor) --gamma 1:1:1

Solution 2:

To see a list of connected displays by name...

$ xrandr --current |grep connected |grep -v disconnected
HDMI1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 510mm x 290mm
HDMI2 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 880mm x 490mm

Set the gamma, specifying one of the connected displays as follows...

xrandr --current --output HDMI1 --gamma 0.5:0.5:0.5

Note: Using --current is not required -- it just speeds things up.