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.
This commit is contained in:
parent
747214f3da
commit
1cd5e2edf7
1 changed files with 16 additions and 5 deletions
|
@ -6,6 +6,7 @@ Parameters:
|
||||||
* bluetooth.manager : application to launch on click (blueman-manager)
|
* bluetooth.manager : application to launch on click (blueman-manager)
|
||||||
* bluetooth.dbus_destination : dbus destination (defaults to org.blueman.Mechanism)
|
* bluetooth.dbus_destination : dbus destination (defaults to org.blueman.Mechanism)
|
||||||
* bluetooth.dbus_destination_path : dbus destination path (defaults to /)
|
* 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,
|
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
||||||
cmd=self.manager)
|
cmd=self.manager)
|
||||||
|
|
||||||
|
# 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,
|
engine.input.register_callback(self,
|
||||||
button=bumblebee.input.RIGHT_MOUSE,
|
button=bumblebee.input.RIGHT_MOUSE,
|
||||||
cmd=self.popup)
|
cmd=self.popup)
|
||||||
|
else:
|
||||||
|
engine.input.register_callback(self,
|
||||||
|
button=bumblebee.input.RIGHT_MOUSE,
|
||||||
|
cmd=self._toggle)
|
||||||
|
|
||||||
def status(self, widget):
|
def status(self, widget):
|
||||||
"""Get status."""
|
"""Get status."""
|
||||||
|
@ -86,11 +97,10 @@ class Module(bumblebee.engine.Module):
|
||||||
# show menu and get return code
|
# show menu and get return code
|
||||||
ret = menu.show(widget)
|
ret = menu.show(widget)
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
logging.debug('bt: toggling bluetooth')
|
|
||||||
# first (and only) item selected.
|
# first (and only) item selected.
|
||||||
self._toggle()
|
self._toggle()
|
||||||
|
|
||||||
def _toggle(self):
|
def _toggle(self, widget=None):
|
||||||
"""Toggle bluetooth state."""
|
"""Toggle bluetooth state."""
|
||||||
if self._status == "On":
|
if self._status == "On":
|
||||||
state = "false"
|
state = "false"
|
||||||
|
@ -104,6 +114,7 @@ class Module(bumblebee.engine.Module):
|
||||||
" {} org.blueman.Mechanism.SetRfkillState"\
|
" {} org.blueman.Mechanism.SetRfkillState"\
|
||||||
" boolean:{}".format(dst, dst_path, state)
|
" boolean:{}".format(dst, dst_path, state)
|
||||||
|
|
||||||
|
logging.debug('bt: toggling bluetooth')
|
||||||
bumblebee.util.execute(cmd)
|
bumblebee.util.execute(cmd)
|
||||||
|
|
||||||
def state(self, widget):
|
def state(self, widget):
|
||||||
|
|
Loading…
Reference in a new issue