Fix info not updating after chnaging time in settings

This commit is contained in:
Gobinath 2016-11-09 08:38:21 +05:30
parent 95b4a53e87
commit 0f603fb87d
2 changed files with 8 additions and 2 deletions

View File

@ -19,7 +19,7 @@
import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk, Gio, GLib, GdkX11
import time, datetime,threading, sys, subprocess, logging
import time, datetime, threading, sys, subprocess, logging
class SafeEyesCore:

View File

@ -25,6 +25,7 @@ import shutil
import errno
import dbus
import logging
from threading import Timer
from dbus.mainloop.glib import DBusGMainLoop
from BreakScreen import BreakScreen
@ -98,14 +99,19 @@ def on_skipped():
def save_settings(config):
logging.info("Saving settings to safeeyes.json")
if is_active:
core.stop()
# Write the configuration to file
with open(config_file_path, 'w') as config_file:
json.dump(config, config_file, indent=4, sort_keys=True)
# Restart the core and intialize the components
logging.info("Initialize SafeEyesCore with modified settings. This will take affect from next break")
logging.info("Initialize SafeEyesCore with modified settings")
core.initialize(config, language)
break_screen.initialize(config, language)
if is_active:
# 1 sec delay is required to give enough time for core to be stopped
Timer(1.0, core.start).start()
def enable_safeeyes():
is_active = True