def main(): """ Start the Safe Eyes. """ # Initialize the logging Utility.intialize_logging() logging.info("Starting Safe Eyes") # Import the dependencies Utility.import_dependencies() if not running(): global break_screen global core global config global notification global tray_icon global language global context global plugins global system_lock_command config = Utility.read_config() context = {} language = Utility.load_language(config['language']) # Get the lock command only one time if config['lock_screen_command']: system_lock_command = config['lock_screen_command'] else: system_lock_command = Utility.lock_screen_command() # Initialize the Safe Eyes Context context['version'] = SAFE_EYES_VERSION context['desktop'] = Utility.desktop_environment() tray_icon = TrayIcon(config, language, show_settings, show_about, enable_safeeyes, disable_safeeyes, on_quit) break_screen = BreakScreen(context, on_skipped, on_postponed, break_screen_glade, Utility.style_sheet_path) break_screen.initialize(config, language) notification = Notification(context, language) plugins = Plugins(config) core = SafeEyesCore(context, show_notification, show_alert, close_alert, break_screen.show_count_down, tray_icon.next_break_time) core.initialize(config, language) plugins.start(context) # Call the start method of all plugins core.start() handle_system_suspend() Gtk.main() else: logging.info('Another instance of safeeyes is already running') sys.exit(0)
def main(): """ Start the Safe Eyes. """ system_locale = gettext.translation('safeeyes', localedir=Utility.LOCALE_PATH, languages=[Utility.system_locale(), 'en_US'], fallback=True) system_locale.install() # locale.bindtextdomain is required for Glade files # gettext.bindtextdomain(gettext.textdomain(), Utility.LOCALE_PATH) locale.bindtextdomain('safeeyes', Utility.LOCALE_PATH) parser = argparse.ArgumentParser(prog='safeeyes', description=_('description')) group = parser.add_mutually_exclusive_group() group.add_argument('-a', '--about', help=_('show the about dialog'), action='store_true') group.add_argument('-d', '--disable', help=_('disable the currently running safeeyes instance'), action='store_true') group.add_argument('-e', '--enable', help=_('enable the currently running safeeyes instance'), action='store_true') group.add_argument('-q', '--quit', help=_('quit the running safeeyes instance and exit'), action='store_true') group.add_argument('-s', '--settings', help=_('show the settings dialog'), action='store_true') group.add_argument('-t', '--take-break', help=_('Take a break now').lower(), action='store_true') parser.add_argument('--debug', help=_('start safeeyes in debug mode'), action='store_true') parser.add_argument('--version', action='version', version='%(prog)s ' + SAFE_EYES_VERSION) args = parser.parse_args() # Initialize the logging Utility.intialize_logging(args.debug) config = Config() if __running(): logging.info("Safe Eyes is already running") rpc_client = RPCClient(config.get('rpc_port')) if args.about: rpc_client.show_about() elif args.disable: rpc_client.disable_safeeyes() elif args.enable: rpc_client.enable_safeeyes() elif args.settings: rpc_client.show_settings() elif args.take_break: rpc_client.take_break() elif args.quit: rpc_client.quit() else: # Default behavior is opening settings rpc_client.show_settings() sys.exit(0) elif not args.quit: logging.info("Starting Safe Eyes") safeeyes = SafeEyes(system_locale, config) safeeyes.start() Timer(1.0, lambda: __evaluate_arguments(args, safeeyes)).start() Gtk.main()