 last_check_inactivity_interval = null
 last_reminder_interval = null
 set_inactivity_check = ->
-    clearInterval last_check_inactivity_interval
-    clearInterval last_reminder_interval
+    clearTimeoutSH last_check_inactivity_interval
+    clearTimeoutSH last_reminder_interval
     check_inactivity = ->
         if not hidden_window
+            last_check_inactivity_interval = setTimeoutSH check_inactivity,
+                settings.inactivity_check_interval
             set_dialog 0
             log.new_entry {active:false, date:show_window_time}
             ui_alarm()
     check_reminder = ->
         if log.is_active and not hidden_window
+            last_reminder_interval = setTimeoutSH check_reminder, settings.reminder_time
             console.log hidden_window, log.is_active
             ui_alarm()
 
-    last_check_inactivity_interval = setInterval check_inactivity,
+    last_check_inactivity_interval = setTimeoutSH check_inactivity,
         settings.inactivity_check_interval
-    last_reminder_interval = setInterval check_reminder, settings.reminder_time
+    last_reminder_interval = setTimeoutSH check_reminder, settings.reminder_time
 
 
 addEventListener 'click', set_inactivity_check


        ui_alarm = (duration=1000)=>
            @setState {alarm:true}
            sounds.notification.play()
            disable_alarm = =>
                @setState {alarm:false}

sound_test = false

apply_settings = ->
    clearTimeoutSH show_window_timeout
    clearTimeoutSH last_check_inactivity_interval

    if settings.open_on_startup
        auto_launcher.isEnabled().then (enabled)->
