summaryrefslogtreecommitdiffstats
path: root/examples/comprehensive
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-13 20:16:14 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-13 20:16:14 +0100
commit3b283d550eaee8511ccf5ad81cad1a3fd8365a0d (patch)
tree8524da53b4ae1f209c53059487774ecbf429ceaf /examples/comprehensive
parentupdate todo (diff)
downloadblueshift-3b283d550eaee8511ccf5ad81cad1a3fd8365a0d.tar.gz
blueshift-3b283d550eaee8511ccf5ad81cad1a3fd8365a0d.tar.bz2
blueshift-3b283d550eaee8511ccf5ad81cad1a3fd8365a0d.tar.xz
fix and demo drm support
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'examples/comprehensive')
-rw-r--r--examples/comprehensive32
1 files changed, 24 insertions, 8 deletions
diff --git a/examples/comprehensive b/examples/comprehensive
index ef8376d..380bf39 100644
--- a/examples/comprehensive
+++ b/examples/comprehensive
@@ -9,6 +9,8 @@
# nor does it parse options other than -r from ad-hoc settigns, or
# use monitor identifiation.
+import os
+
# Geographical coodinates.
# (KTH building D computer laboratories in this example.)
@@ -41,6 +43,16 @@ def by_time():
return 1 # Error in `time_alpha` (probably)
+# Check if we are in X or TTY.
+ttymode = not (('DISPLAY' in os.environ) and (':' in os.environ['DISPLAY']))
+
+# Method for applying colour curves.
+apply_curves = randr
+#apply_curves = vidmode
+if ttymode:
+ apply_curves = drm
+
+
# Keep uncomment to use solar position.
get_dayness = lambda : sun(latitude, longitude)
# Uncomment to use time of day.
@@ -132,9 +144,13 @@ icc_calibration_profile = [None]
# -p (--panicgate) is used.
current_calibration = [None]
if not panicgate:
- calib_get = None
- #calib_get = randr_get
- #calib_get = vidmode_get
+ if not ttymode:
+ calib_get = None
+ #calib_get = randr_get
+ #calib_get = vidmode_get
+ else:
+ calib_get = None
+ #calib_get = drm_get
current_calibration = [calib_get]
@@ -178,7 +194,7 @@ for i in range(len(current_calibration)):
current_calibration[i] = f(m)
-monitor_controller = lambda : randr(*monitors)
+monitor_controller = lambda : apply_curves(*monitors)
'''
:()→void Function used by Blueshift on exit to apply reset colour curves, if using preimplemented `reset`
'''
@@ -335,9 +351,9 @@ def periodically(year, month, day, hour, minute, second, weekday, fade):
# Flush settings to monitor.
if len(monitors) == 0:
- randr()
+ apply_curves()
else:
- randr(monitors[m % len(monitors)])
+ apply_curves(monitors[m % len(monitors)])
# Lets wait only 5 seconds, instead of a minute before running again.
wait_period = 5
@@ -372,9 +388,9 @@ def reset():
# Flush settings to monitor.
if len(monitors) == 0:
- randr()
+ apply_curves()
else:
- randr(monitors[m % len(monitors)])
+ apply_curves(monitors[m % len(monitors)])
if (get_dayness is not None) and not doreset: