summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-20 22:54:33 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-20 22:54:33 +0100
commit20353df6527d4d16029700d7ae68a4b72a46cd31 (patch)
treeea4114c0c4d455adf8575c2e5a5c53c61339e93d /src
parentfix pkgbuild to install info (diff)
downloadblueshift-20353df6527d4d16029700d7ae68a4b72a46cd31.tar.gz
blueshift-20353df6527d4d16029700d7ae68a4b72a46cd31.tar.bz2
blueshift-20353df6527d4d16029700d7ae68a4b72a46cd31.tar.xz
sigusr1 for reloading
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/__main__.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/__main__.py b/src/__main__.py
index 6aa0e2a..405bd76 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -31,7 +31,7 @@ PROGRAM_VERSION = '1.1'
## Set global variables
global DATADIR, i_size, o_size, r_curve, g_curve, b_curve, clip_result, reset, panicgate
global periodically, wait_period, fadein_time, fadeout_time, fadein_steps, fadeout_steps
-global monitor_controller, running, continuous_run, panic
+global monitor_controller, running, continuous_run, panic, _globals_
global signal_SIGTERM
@@ -153,6 +153,26 @@ def signal_SIGTERM(signum, frame):
running = False
+
+_globals_, _locals_ = globals(), dict(locals())
+for key in _locals_:
+ _globals_[key] = _locals_[key]
+def signal_SIGUSR1(signum, frame):
+ '''
+ Signal handler for SIGUSR1
+
+ @param signum The signal number, 0 if called from the program itself
+ @param frame Ignore, it will probably be `None`
+ '''
+ code = None
+ with open(config_file, 'rb') as script:
+ code = script.read()
+ code = code.decode('utf8', 'error') + '\n'
+ code = compile(code, config_file, 'exec')
+ exec(code, _globals_)
+
+
+
def continuous_run():
'''
Invoked to run continuously if `periodically` is not `None`
@@ -172,6 +192,7 @@ def continuous_run():
## Catch signals
signal.signal(signal.SIGTERM, signal_SIGTERM)
+ signal.signal(signal.SIGUSR1, signal_SIGUSR1)
## Fade in
early_exit = False