summaryrefslogtreecommitdiffstats
path: root/src/__main__.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-16 02:54:10 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-16 02:54:10 +0100
commit4ab20ce9fc0dd4fe6baf022e4cd92cb630555e26 (patch)
tree5c34bdd88693a5dd6efca42b3e3b98a471abcb58 /src/__main__.py
parentm (diff)
downloadblueshift-4ab20ce9fc0dd4fe6baf022e4cd92cb630555e26.tar.gz
blueshift-4ab20ce9fc0dd4fe6baf022e4cd92cb630555e26.tar.bz2
blueshift-4ab20ce9fc0dd4fe6baf022e4cd92cb630555e26.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/__main__.py')
-rwxr-xr-xsrc/__main__.py53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/__main__.py b/src/__main__.py
index be4be42..1170aa8 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -20,17 +20,24 @@ import time
import signal
import datetime
-from colour import *
from curve import *
+from colour import *
from monitor import *
+config_file = None
+
+
## Set globals variables
global DATADIR, i_size, o_size, r_curve, g_curve, b_curve, clip_result
global periodically, wait_period, monitor_controller, running
def periodically(year, month, day, hour, minute, second, weekday, fade):
+ fadein_time = None
+ fadeout_time = None
+ fadein_steps = 100
+ fadeout_steps = 100
if fade is None:
negative(False, False, False)
temperature(6500, lambda T : divide_by_maximum(series_d(T)), True)
@@ -121,25 +128,31 @@ running = True
## Load extension and configurations via blueshiftrc
-for file in ('$XDG_CONFIG_HOME/%/%rc', '$HOME/.config/%/%rc', '$HOME/.%rc', '/etc/%rc'):
- file = file.replace('%', 'blueshift')
- for arg in ('XDG_CONFIG_HOME', 'HOME'):
- if arg in os.environ:
- print(arg)
- file = file.replace('$' + arg, os.environ[arg].replace('$', '\0'))
- else:
- file = None
- break
- if file is not None:
- file = file.replace('\0', '$')
- if os.path.exists(file):
- code = None
- with open(file, 'rb') as script:
- code = script.read()
- code = code.decode('utf8', 'error') + '\n'
- code = compile(code, file, 'exec')
- exec(code, globals)
- break
+if config_file is None:
+ for file in ('$XDG_CONFIG_HOME/%/%rc', '$HOME/.config/%/%rc', '$HOME/.%rc', '/etc/%rc'):
+ file = file.replace('%', 'blueshift')
+ for arg in ('XDG_CONFIG_HOME', 'HOME'):
+ if arg in os.environ:
+ print(arg)
+ file = file.replace('$' + arg, os.environ[arg].replace('$', '\0'))
+ else:
+ file = None
+ break
+ if file is not None:
+ file = file.replace('\0', '$')
+ if os.path.exists(file):
+ config_file = file
+if config_file is not None:
+ code = None
+ with open(file, 'rb') as script:
+ code = script.read()
+ code = code.decode('utf8', 'error') + '\n'
+ code = compile(code, file, 'exec')
+ exec(code, globals)
+ break
+else:
+ print('No configuration file found')
+ sys.exit(1)
## Run periodically if configured to