def run(self):
        """Thread loop."""

        def is_update_time(seconds, now):
            """Check if time to update."""

            update = False
            if (
                not ThemeScheduler.busy and
                ThemeScheduler.next_change is not None and
                not ThemeScheduler.update and
                ThemeScheduler.day is not None
            ):
                if ThemeScheduler.day == now.day:
                    # Comparing time on the same day
                    # If the next change also equals the lowest,
                    # it is the first change of the day.
                    # Wait for the next day.
                    update = (
                        seconds >= ThemeScheduler.next_change.time and
                        ThemeScheduler.next_change.time != ThemeScheduler.lowest.time
                    )
                else:
                    # Its a new day.  If the time is greater than the next or
                    # even the lowest, update theme.
                    update = (
                        seconds >= ThemeScheduler.next_change.time or
                        seconds >= ThemeScheduler.lowest.time
                    )
            return update

        sublime.set_timeout(lambda: self.payload(self.INIT), 0)

        while not self.abort:
            # Pop back into the main thread and check if time to change theme
            seconds, now = get_current_time()
            if ThemeScheduler.update:
                ThemeScheduler.update = False
                ThemeScheduler.busy = False
                debug_log("Button defferal")
                debug_log("Is busy: %s" % str(ThemeScheduler.busy))
                debug_log(
                    "Compare: day: %s now: %s next: %s current: %s" % (
                        ThemeScheduler.day if ThemeScheduler.day is not None else "None",
                        now.day,
                        sec2time(ThemeScheduler.next_change.time) if ThemeScheduler.next_change is not None else "None",
                        sec2time(seconds)
                    )
                )
                sublime.set_timeout(lambda s=seconds, n=now: self.payload(self.POST_DIALOG, s, n), 0)
            elif ThemeScheduler.ready and is_update_time(seconds, now):
                debug_log("Time to update")
                debug_log("Is busy: %s" % str(ThemeScheduler.busy))
                debug_log(
                    "Compare: day: %s now: %s next: %s current: %s" % (
                        ThemeScheduler.day if ThemeScheduler.day is not None else "None",
                        now.day,
                        sec2time(ThemeScheduler.next_change.time) if ThemeScheduler.next_change is not None else "None",
                        sec2time(seconds)
                    )
                )
                sublime.set_timeout(lambda s=seconds, n=now: self.payload(self.CHANGE, s, n), 0)
            time.sleep(1)
dataset/ETHPy150Open facelessuser/ThemeScheduler/ThemeScheduler.py/TsThread.run/original