summaryrefslogtreecommitdiffstats
path: root/src/__main__.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-16 01:38:26 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-16 01:38:26 +0100
commit4c0b64a6f81b678824c35a16db9ba04462e36d32 (patch)
tree53e4ea346644321eccf6c822ffdc3d753c434c0f /src/__main__.py
parentuse periodically (diff)
downloadblueshift-4c0b64a6f81b678824c35a16db9ba04462e36d32.tar.gz
blueshift-4c0b64a6f81b678824c35a16db9ba04462e36d32.tar.bz2
blueshift-4c0b64a6f81b678824c35a16db9ba04462e36d32.tar.xz
signal handling
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/__main__.py')
-rwxr-xr-xsrc/__main__.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/__main__.py b/src/__main__.py
index 881b3c1..03d99b8 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -15,7 +15,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
+import sys
import time
+import signal
import datetime
from colour import *
@@ -147,6 +149,16 @@ if periodically is not None:
wd = t.isocalendar()[2]
periodically(t.year, t.month, t.day, t.hour, t.minute, t.second, wd, fade)
+ ## Catch TERM signal
+ def signal_SIGTERM(signum, frame):
+ if not running:
+ running = False
+ start_over()
+ monitor_controller()
+ sys.exit(0)
+ running = False
+ signal.signal(signal.SIGTERM, signal_SIGTERM)
+
## Fade in
early_exit = False
ftime = 0