def sync_with_config(self): # sets the scheduled button to be enabled or disabled if config.is_scheduled(): self.ui.schedule_radio.setChecked(True) self.ui.dark_time.setEnabled(True) self.ui.light_time.setEnabled(True) yin_yang.start_daemon() # sets the correct time based on config self.set_correct_time() # setting the correct buttons based on config "dark" "light" self.set_correct_buttons()
def main(): # using ArgumentParser for parsing arguments parser = ArgumentParser() parser.add_argument("-t", "--toggle", help="toggles Yin-Yang", action="store_true") parser.add_argument("-s", "--schedule", help="schedule theme toggle, starts daemon in bg", action="store_true") args = parser.parse_args() # Check and see if there are new keys we need to add to the config. should_update_config = assembly_version != config.get_version() if should_update_config: update_config() # checks whether $ yin-yang is ran without args if len(sys.argv) == 1 and not args.toggle: # load GUI app = QtWidgets.QApplication(sys.argv) window = gui.MainWindow() window.show() sys.exit(app.exec_()) # checks whether the script should be ran as a daemon if args.schedule: config.update("running", False) print("START thread listener") if config.get("followSun"): # calculate time if needed config.set_sun_time() if config.get("schedule"): yin_yang.start_daemon() else: print("looks like you did not specified a time") print("You can use the gui with yin-yang -gui") print( "Or edit the config found in ~/.config/yin_yang/yin_yang.json") print( "You need to set schedule to True and edit the time to toggles" ) # gui is set as parameter if args.toggle: toggle_theme()
def main(): # using ArgumentParser for parsing arguments parser = ArgumentParser() parser.add_argument("-t", "--toggle", help="toggles Yin-Yang", action="store_true") parser.add_argument("-s", "--schedule", help="schedule theme toggle, starts daemon in bg", action="store_true") args = parser.parse_args() # checks whether $ yin-yang is ran without args if len(sys.argv) == 1 and not args.toggle: # load GUI app = QtWidgets.QApplication(sys.argv) window = gui.MainWindow() window.show() sys.exit(app.exec_()) # checks whether the script should be ran as a daemon if args.schedule: config.update("running", False) logger.debug("START thread listener") if config.get("followSun"): # calculate time if needed config.set_sun_time() if config.get("schedule"): yin_yang.start_daemon() else: logger.warning( "Tried to start scheduler, but schedule was not enabled.") print( "Looks like you have not specified a time." "You can use the GUI by running Yin & Yang or " "edit the config found in ~/.config/yin_yang/yin_yang.json." "You need to set schedule to true and edit the time to toggles." ) if args.toggle: # terminate any running instances config.update("running", False) config.update("followSun", False) config.update("schedule", False) toggle_theme()