From c026b357a086d835108de1cf2debd08c0cacefb3 Mon Sep 17 00:00:00 2001 From: Brikwerk Date: Sat, 12 Sep 2020 22:03:56 -0700 Subject: [PATCH] Added option to run as rootless user --- nxbt/bluez.py | 3 --- nxbt/nxbt.py | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nxbt/bluez.py b/nxbt/bluez.py index b08cedd..97ebc34 100644 --- a/nxbt/bluez.py +++ b/nxbt/bluez.py @@ -103,9 +103,6 @@ def toggle_input_plugin(toggle): :raises Exception: If the units can't be reloaded """ - if os.geteuid() != 0: - raise PermissionError("The input plugin must be toggled as root") - service_path = "/lib/systemd/system/bluetooth.service" service = None with open(service_path, "r") as f: diff --git a/nxbt/nxbt.py b/nxbt/nxbt.py index dd097fd..3c9f1da 100644 --- a/nxbt/nxbt.py +++ b/nxbt/nxbt.py @@ -177,7 +177,10 @@ class Nxbt(): # Disable the BlueZ input plugin so we can use the # HID control/interrupt Bluetooth ports - toggle_input_plugin(False) + try: + toggle_input_plugin(False) + except PermissionError: + pass # Exit handler atexit.register(self._on_exit) @@ -661,6 +664,7 @@ class Nxbt(): "initializing" or "connecting" or "reconnecting" or + "connected" or "crashed" "finished_macros": A list of UUIDs @@ -771,6 +775,7 @@ class _ControllerManager(): def remove_controller(self, index): self._children[index].kill() + self.state.pop(index, None) def shutdown(self):