summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--examples/crtc-detection34
-rwxr-xr-xsrc/__main__.py3
-rw-r--r--src/monitor.py4
4 files changed, 39 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 32c9763..b1d6d51 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ PYFILES = __main__.py colour.py curve.py monitor.py solar.py icc.py adhoc.py
# Library files
CBINDINGS = $(foreach B,$(SERVER_BINDINGS),blueshift_$(B).so)
# Configuration script example files
-EXAMPLES = comprehensive sleepmode
+EXAMPLES = comprehensive sleepmode crtc-detection
# Build rules
diff --git a/examples/crtc-detection b/examples/crtc-detection
new file mode 100644
index 0000000..5f60d6c
--- /dev/null
+++ b/examples/crtc-detection
@@ -0,0 +1,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)
+
diff --git a/src/__main__.py b/src/__main__.py
index 1e966ed..22973ac 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -363,6 +363,7 @@ temperatures = parser.opts['--temperature']
output = parser.opts['--output']
if output is None:
output = []
+used_adhoc = any([doreset, location, gammas, rgb_brightnesses, cie_brightnesses, temperatures, output])
## Verify option correctness
a = lambda opt : 0 if parser.opts[opt] is None else len(parser.opts[opt])
@@ -429,7 +430,7 @@ else:
## Warn about ad-hoc settings
if not uses_adhoc_opts:
- if any([doreset, location, gammas, rgb_brightnesses, cie_brightnesses, temperatures, output]):
+ if used_adhoc:
print('%s: warning: --configurations can only be combined with --panicgate' % sys.argv[0])
parser = None
diff --git a/src/monitor.py b/src/monitor.py
index f09db6d..f8a699a 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -374,7 +374,7 @@ class Output:
self.name = None
self.connected = False
self.widthmm = None
- self.heigthmm = None
+ self.heightmm = None
self.crtc = None
self.screen = None
@@ -382,7 +382,7 @@ class Output:
'''
Return a string representation of the instance
'''
- rc = [self.name, self.connected, self.widthmm, self.heigthmm, self.crtc, self.screen]
+ rc = [self.name, self.connected, self.widthmm, self.heightmm, self.crtc, self.screen]
rc = tuple([self.name] + list(map(lambda x : repr(x), rc[1:])))
rc = '[Name: %s, Connected: %s, Width: %s, Height: %s, CRTC: %s, Screen: %s]' % rc
return rc