From d1c5cd5e5d12f1d550a29e6e61b2fd80e9ad24b6 Mon Sep 17 00:00:00 2001 From: Jayofelony Date: Mon, 16 Dec 2024 20:30:37 +0100 Subject: [PATCH] Disconnect BT when disabling plugin. Signed-off-by: Jeroen Oudshoorn --- pwnagotchi/plugins/default/bt-tether.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pwnagotchi/plugins/default/bt-tether.py b/pwnagotchi/plugins/default/bt-tether.py index 8a1dffba..a9d002e2 100644 --- a/pwnagotchi/plugins/default/bt-tether.py +++ b/pwnagotchi/plugins/default/bt-tether.py @@ -79,4 +79,10 @@ class BTTether(plugins.Plugin): def on_unload(self, ui): with ui._lock: - ui.remove_element('bluetooth') \ No newline at end of file + ui.remove_element('bluetooth') + try: + mac = self.options['mac'] + subprocess.run(['nmcli', 'device', 'disconnect', f'{mac}'], check=True) + logging.info(f"[BT-Tether] Disconnected from device with MAC: {mac}") + except Exception as e: + logging.error(f"[BT-Tether] Failed to disconnect from device: {e}") \ No newline at end of file