when toggling a plugin, changed to save config after running load/unload handlers, in case those change the config

This commit is contained in:
Sniffleupagus
2023-05-21 17:16:58 -07:00
parent d2c52e2673
commit fc2341b04c

View File

@ -47,13 +47,13 @@ def toggle_plugin(name, enable=True):
if not name in pwnagotchi.config['main']['plugins']: if not name in pwnagotchi.config['main']['plugins']:
pwnagotchi.config['main']['plugins'][name] = dict() pwnagotchi.config['main']['plugins'][name] = dict()
pwnagotchi.config['main']['plugins'][name]['enabled'] = enable pwnagotchi.config['main']['plugins'][name]['enabled'] = enable
save_config(pwnagotchi.config, '/etc/pwnagotchi/config.toml')
if not enable and name in loaded: if not enable and name in loaded:
if getattr(loaded[name], 'on_unload', None): if getattr(loaded[name], 'on_unload', None):
loaded[name].on_unload(view.ROOT) loaded[name].on_unload(view.ROOT)
del loaded[name] del loaded[name]
if pwnagotchi.config:
save_config(pwnagotchi.config, '/etc/pwnagotchi/config.toml')
return True return True
if enable and name in database and name not in loaded: if enable and name in database and name not in loaded:
@ -65,6 +65,8 @@ def toggle_plugin(name, enable=True):
one(name, 'config_changed', pwnagotchi.config) one(name, 'config_changed', pwnagotchi.config)
one(name, 'ui_setup', view.ROOT) one(name, 'ui_setup', view.ROOT)
one(name, 'ready', view.ROOT._agent) one(name, 'ready', view.ROOT._agent)
if pwnagotchi.config:
save_config(pwnagotchi.config, '/etc/pwnagotchi/config.toml')
return True return True
return False return False