From a20a442bd3f486955d124ed3a664e24fa0dacbce Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 27 Oct 2009 03:59:10 +0800 Subject: Added --auto-close option to the event manager. --- examples/data/uzbl/scripts/event_manager.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'examples/data/uzbl/scripts') diff --git a/examples/data/uzbl/scripts/event_manager.py b/examples/data/uzbl/scripts/event_manager.py index aaf3295..9c269c7 100755 --- a/examples/data/uzbl/scripts/event_manager.py +++ b/examples/data/uzbl/scripts/event_manager.py @@ -71,6 +71,7 @@ CACHE_DIR = os.path.join(xdghome('CACHE', '.cache/'), 'uzbl/') config = { 'verbose': False, 'daemon_mode': True, + 'auto_close': False, 'plugins_load': [], 'plugins_ignore': [], @@ -664,16 +665,18 @@ class UzblEventDaemon(dict): '''Clean up after instance close.''' try: - if client not in self['uzbls']: - return - - uzbl = self['uzbls'][client] - uzbl.close() - del self['uzbls'][client] + if client in self['uzbls']: + uzbl = self['uzbls'][client] + uzbl.close() + del self['uzbls'][client] except: print_exc() + if not len(self['uzbls']) and config['auto_close']: + echo('auto closing event manager.') + self.running = False + def quit(self): '''Close all instance socket objects, server socket and delete the @@ -783,6 +786,9 @@ if __name__ == "__main__": parser.add_option('-n', '--no-daemon', dest="daemon", action="store_true", help="don't enter daemon mode.") + parser.add_option('-a', '--auto-close', dest='autoclose', + action='store_true', help='auto close after all instances disconnect.') + (options, args) = parser.parse_args() # init like {start|stop|..} daemon control section. @@ -831,6 +837,10 @@ if __name__ == "__main__": echo('ignoring plugin(s): %s' % ', '.join(plugins_ignore)) + if options.autoclose: + config['auto_close'] = True + echo('will auto close.') + if options.pid: config['pid_file'] = options.pid echo("pid file location: %r" % config['pid_file']) -- cgit v1.2.3