From 747214f3da281670cfe86dc99ad8b6e47408aa08 Mon Sep 17 00:00:00 2001 From: Pi-Yueh Chuang Date: Wed, 18 Dec 2019 16:39:48 -0500 Subject: [PATCH 1/2] configurable D-Bus blueman object path to fix #483 The path to object org.blueman.Mechanism was originally hard-coded to "/". But in some systems, the path may be "/org/blueman/mechanism". So this commit adds an extra parameter to configure the path. --- bumblebee/modules/bluetooth.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/bluetooth.py b/bumblebee/modules/bluetooth.py index 949be09..a43f43b 100644 --- a/bumblebee/modules/bluetooth.py +++ b/bumblebee/modules/bluetooth.py @@ -5,6 +5,7 @@ Parameters: * bluetooth.device : the device to read state from (default is hci0) * bluetooth.manager : application to launch on click (blueman-manager) * bluetooth.dbus_destination : dbus destination (defaults to org.blueman.Mechanism) + * bluetooth.dbus_destination_path : dbus destination path (defaults to /) """ @@ -97,10 +98,11 @@ class Module(bumblebee.engine.Module): state = "true" dst = self.parameter("dbus_destination", "org.blueman.Mechanism") + dst_path = self.parameter("dbus_destination_path", "/") cmd = "dbus-send --system --print-reply --dest={}"\ - " / org.blueman.Mechanism.SetRfkillState"\ - " boolean:{}".format(dst, state) + " {} org.blueman.Mechanism.SetRfkillState"\ + " boolean:{}".format(dst, dst_path, state) bumblebee.util.execute(cmd) From 1cd5e2edf7cd5bbaea8c4ebd2efda3831f76c0a8 Mon Sep 17 00:00:00 2001 From: Pi-Yueh Chuang Date: Wed, 18 Dec 2019 16:53:58 -0500 Subject: [PATCH 2/2] add a parameter to control bluetooth popup menu The right-click popup menu in the bluetooth module does not work well in Sway (a i3wm-compatible Wayland WM). This is known issue to Sway. Given that the popup menu is simply to turn on/off the bluetooth device, the graphical popup is really not necessary. This commit adds a parameter to control whether a popup menu should be used when a right-click happens, or we simply turn on/off the device without the menu. --- bumblebee/modules/bluetooth.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bumblebee/modules/bluetooth.py b/bumblebee/modules/bluetooth.py index a43f43b..fc5d5b5 100644 --- a/bumblebee/modules/bluetooth.py +++ b/bumblebee/modules/bluetooth.py @@ -6,6 +6,7 @@ Parameters: * bluetooth.manager : application to launch on click (blueman-manager) * bluetooth.dbus_destination : dbus destination (defaults to org.blueman.Mechanism) * bluetooth.dbus_destination_path : dbus destination path (defaults to /) + * bluetooth.right_click_popup : use popup menu when right-clicked (defaults to True) """ @@ -36,9 +37,19 @@ class Module(bumblebee.engine.Module): engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd=self.manager) - engine.input.register_callback(self, - button=bumblebee.input.RIGHT_MOUSE, - cmd=self.popup) + + # determine whether to use pop-up menu or simply toggle the device on/off + right_click_popup = bumblebee.util.asbool( + self.parameter("right_click_popup", True)) + + if right_click_popup: + engine.input.register_callback(self, + button=bumblebee.input.RIGHT_MOUSE, + cmd=self.popup) + else: + engine.input.register_callback(self, + button=bumblebee.input.RIGHT_MOUSE, + cmd=self._toggle) def status(self, widget): """Get status.""" @@ -86,11 +97,10 @@ class Module(bumblebee.engine.Module): # show menu and get return code ret = menu.show(widget) if ret == 0: - logging.debug('bt: toggling bluetooth') # first (and only) item selected. self._toggle() - def _toggle(self): + def _toggle(self, widget=None): """Toggle bluetooth state.""" if self._status == "On": state = "false" @@ -104,6 +114,7 @@ class Module(bumblebee.engine.Module): " {} org.blueman.Mechanism.SetRfkillState"\ " boolean:{}".format(dst, dst_path, state) + logging.debug('bt: toggling bluetooth') bumblebee.util.execute(cmd) def state(self, widget):