diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index 1cef7d6..f3b9b55 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -3,6 +3,7 @@ import glob import _thread import importlib, importlib.util import logging +from pwnagotchi.ui import view default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default") loaded = {} @@ -27,14 +28,14 @@ def toggle_plugin(name, enable=True): global loaded, database if not enable and name in loaded: if getattr(loaded[name], 'on_unload', None): - loaded[name].on_unload() + loaded[name].on_unload(view.ROOT) del loaded[name] return True if enable and name in database and name not in loaded: load_from_file(database[name]) one(name, 'loaded') - one(name, 'ui_setup') + one(name, 'ui_setup', view.ROOT) return True return False diff --git a/pwnagotchi/plugins/default/bt-tether.py b/pwnagotchi/plugins/default/bt-tether.py index 5f986f8..593fe16 100644 --- a/pwnagotchi/plugins/default/bt-tether.py +++ b/pwnagotchi/plugins/default/bt-tether.py @@ -466,11 +466,10 @@ class BTTether(plugins.Plugin): logging.info("BT-TETHER: Successfully loaded ...") self.ready = True - def on_unload(self): - self.ui.remove_element('bluetooth') + def on_unload(self, ui): + ui.remove_element('bluetooth') def on_ui_setup(self, ui): - self.ui = ui ui.add_element('bluetooth', LabeledValue(color=BLACK, label='BT', value='-', position=(ui.width() / 2 - 15, 0), label_font=fonts.Bold, text_font=fonts.Medium)) diff --git a/pwnagotchi/plugins/default/example.py b/pwnagotchi/plugins/default/example.py index 58fe448..cf30827 100644 --- a/pwnagotchi/plugins/default/example.py +++ b/pwnagotchi/plugins/default/example.py @@ -26,7 +26,7 @@ class Example(plugins.Plugin): logging.warning("WARNING: this plugin should be disabled! options = " % self.options) # called before the plugin is unloaded - def on_unload(self): + def on_unload(self, ui): pass # called hen there's internet connectivity