summaryrefslogtreecommitdiffstats
path: root/examples/crtc-detection
blob: 5f60d6cba1bf28f524d3b7e61ea0ffe5ae9bafab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- python -*-

# This example identifies which monitors you have plugged
# in to the computer, and applied their proper calibration.


# The colour temperature to apply.
temp = 6500

# List all connected outputs.
outputs = list_screens().find_by_connected(True)

# Configure each monitor.
for output in outputs:
    # Data that identifies the monitor.
    monitor = (output.name, output.widthmm, output.heightmm)
    
    # Default gamma settings.
    r_gamma, g_gamma, b_gamma = 1, 1, 1
    
    # Get the correct gamma settings for the monitor.
    if   monitor == ('DVI-0', 364, 291):  r_gamma, g_gamma, b_gamma = 1.16, 1.15, 1.11
    elif monitor == ('VGA-0', 364, 291):  r_gamma, g_gamma, b_gamma = 1.10, 1.16, 1.10
    else:
        print('Warning: unknown monitor at %s at size of %i mm by %i mm' % monitor)
    
    # Perform adjustments.
    start_over()
    temperature(temp, lambda t : divide_by_maximum(cmf_10deg(t)))
    gamma(r_gamma, g_gamma, b_gamma)
    
    # Apply adjustments.
    randr(output.crtc, screen = output.screen)