summaryrefslogtreecommitdiffstats
path: root/examples/stored-settings
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/stored-settings
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/stored-settings')
-rw-r--r--examples/stored-settings11
1 files changed, 9 insertions, 2 deletions
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):