summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-14 03:06:20 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-14 03:08:02 +0100
commit581dbd784a5f6bdd1b064e44e27066ce687f5dd8 (patch)
tree47ea9153c1079ea6abe53b043451ab2efba6cd6b /examples
parentreduce allocations in drm (diff)
downloadblueshift-581dbd784a5f6bdd1b064e44e27066ce687f5dd8.tar.gz
blueshift-581dbd784a5f6bdd1b064e44e27066ce687f5dd8.tar.bz2
blueshift-581dbd784a5f6bdd1b064e44e27066ce687f5dd8.tar.xz
add ttymode support for all examples missing it and uses randr or vidmode, except the xmonad example becuase xmonad does not run in tty1.10
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/current-settings4
-rw-r--r--examples/lisp-esque.conf6
-rw-r--r--examples/logarithmic4
-rw-r--r--examples/sleepmode8
-rw-r--r--examples/stored-settings11
-rw-r--r--examples/threaded7
6 files changed, 27 insertions, 13 deletions
diff --git a/examples/current-settings b/examples/current-settings
index 8c8afe8..62d5e7d 100644
--- a/examples/current-settings
+++ b/examples/current-settings
@@ -15,7 +15,7 @@ temperature_to = int(parser.opts['--temperature'][0])
# Get current colour curves
-randr_get(0)()
+(drm_get if ttymode else randr_get)(0)()
r_, g_, b_ = r_curve[:], g_curve[:], b_curve[:]
start_over()
@@ -41,7 +41,7 @@ def adjust(alpha):
ccc = [(out, list(map(f, zip(old, new)))) for out, (old, new) in ccc]
for out, curve in ccc:
out[:] = curve
- randr(0)
+ (drm if ttymode else randr)(0)
# Perform transition
if divergence and not panicgate:
diff --git a/examples/lisp-esque.conf b/examples/lisp-esque.conf
index cd9116f..c9dad3c 100644
--- a/examples/lisp-esque.conf
+++ b/examples/lisp-esque.conf
@@ -89,6 +89,8 @@
; (method print)
; It is possible to use both:
; (method print randr)
+ ; drm does not exist as an alternative but will be used
+ ; automatically under ttymode.
(transfrom randr) ; yes, this it says ‘from’ not ‘form’
@@ -101,6 +103,8 @@
; It an also be configured individually for the monitors:
; (transfrom randr nil)
; This will not do this for the second monitor
+ ; drm does not exist as an alternative but will be used
+ ; automatically under ttymode.
;; Important: The following options are applied in order of appearance
@@ -161,6 +165,8 @@
; (current vidmode) ; of using vidmode
; You can also controll the monitors individually:
; (current randr nil) ; does this only for the first monitor
+ ; drm does not exist as an alternative but will be used
+ ; automatically under ttymode.
; Colour brightness at high day and high night, respectively.
; This setting uses the CIE xyY colour space for calculating values.
diff --git a/examples/logarithmic b/examples/logarithmic
index 8dc137e..7113534 100644
--- a/examples/logarithmic
+++ b/examples/logarithmic
@@ -19,6 +19,6 @@ manipulate(lambda x : math.log(x + 1, 2))
standardise()
# Apply settings, using vidmode.
-vidmode()
-#randr()
+(drm if ttymode else vidmode)()
+#(drm if ttymode else randr)()
diff --git a/examples/sleepmode b/examples/sleepmode
index 00ec3dd..8713b63 100644
--- a/examples/sleepmode
+++ b/examples/sleepmode
@@ -123,9 +123,9 @@ def periodically(year, month, day, hour, minute, second, weekday, fade):
# Flush settings to monitor.
if len(monitors) == 0:
- randr()
+ (drm if ttymode else randr)()
else:
- randr(monitors[m % len(monitors)])
+ (drm if ttymode else randr)(monitors[m % len(monitors)])
def reset():
@@ -144,7 +144,7 @@ def reset():
# Flush settings to monitor.
if len(monitors) == 0:
- randr()
+ (drm if ttymode else randr)()
else:
- randr(monitors[m % len(monitors)])
+ (drm if ttymode else randr)(monitors[m % len(monitors)])
diff --git a/examples/stored-settings b/examples/stored-settings
index e3b45c0..cc87cff 100644
--- a/examples/stored-settings
+++ b/examples/stored-settings
@@ -18,7 +18,14 @@ temperature_to = int(parser.opts['--temperature'][0])
# Get old temperature setting
temperature_from = 6500
-storage_file = '/dev/shm/.blueshift-conf-%s-%s' % (os.environ['DISPLAY'], os.environ['USER'])
+def env_(var, default):
+ if var not in os.environ:
+ return default
+ rc = os.environ[var]
+ if rc == '':
+ rc = default
+ return rc
+storage_file = '/dev/shm/.blueshift-conf-%s-%s' % (env_('DISPLAY', 'tty'), os.environ['USER'])
if os.path.exists(storage_file):
with open(storage_file, 'rb') as file:
temperature_from = int(file.read().decode('utf-8', 'replace').split('\n')[0])
@@ -37,7 +44,7 @@ def adjust(alpha):
temp = temperature_to * alpha + temperature_from * (1 - alpha)
start_over()
temperature(temp, lambda t : divide_by_maximum(cmf_10deg(t)))
- randr(0)
+ (drm if ttymode else randr)(0)
# Perform transition
if not (panicgate or temperature_to == temperature_from):
diff --git a/examples/threaded b/examples/threaded
index e70d33e..68914ec 100644
--- a/examples/threaded
+++ b/examples/threaded
@@ -70,7 +70,8 @@ interpol, purify = None, None
fade_ = None
# randr is not threadsafe, and absolutely not if you have multiple screens.
-# This semaphore is used to make sure that two threads are not accessing randr at the same time.
+# drm can be threadsafe but is by default not.
+# This semaphore is used to make sure that two threads are not accessing randr or drm at the same time.
flush_semaphore = threading.Semaphore()
@@ -103,7 +104,7 @@ def adjust(m):
# Flush settings to monitor.
flush_semaphore.acquire()
- randr(m)
+ (drm if ttymode else randr)(m)
flush_semaphore.release()
# Signal thread completion.
@@ -185,7 +186,7 @@ def reset():
gamma(gamma_red[m], gamma_green[m], gamma_blue[m])
# Flush settings to monitor.
- randr(m)
+ (drm if ttymode else randr)(m)
# Set transition time, 0 on high day and 5 seconds on high night.