[modules/xrandr] Add refresh widget when autoupdate==False

If polling displays via xrandr is disabled, show an additional widget
that allows the user to manually refresh the widget list.

see #359
This commit is contained in:
Tobias Witek 2019-02-08 20:11:48 +01:00
parent 8511e57ed2
commit a198b8d9e3
3 changed files with 12 additions and 2 deletions

View file

@ -58,12 +58,21 @@ class Module(bumblebee.engine.Module):
for widget in new_widgets: for widget in new_widgets:
widgets.append(widget) widgets.append(widget)
if self._autoupdate == False:
widget = bumblebee.output.Widget(full_text="")
widget.set("state", "refresh")
self._engine.input.register_callback(widget, button=1, cmd=self._refresh)
widgets.append(widget)
def update(self, widgets): def update(self, widgets):
self.update_widgets(widgets) self.update_widgets(widgets)
def state(self, widget): def state(self, widget):
return widget.get("state", "off") return widget.get("state", "off")
def _refresh(self, event):
self._needs_update = True
def _toggle(self, event): def _toggle(self, event):
self._needs_update = True self._needs_update = True
path = os.path.dirname(os.path.abspath(__file__)) path = os.path.dirname(os.path.abspath(__file__))

View file

@ -77,7 +77,7 @@
"activated": {"prefix": "caf-on" }, "deactivated": { "prefix": "caf-off " } "activated": {"prefix": "caf-on" }, "deactivated": { "prefix": "caf-off " }
}, },
"xrandr": { "xrandr": {
"on": { "prefix": " off "}, "off": { "prefix": " on "} "on": { "prefix": " off "}, "off": { "prefix": " on "}, "refresh": { "prefix": " refresh "}
}, },
"redshift": { "redshift": {
"day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" } "day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" }

View file

@ -122,7 +122,8 @@
}, },
"xrandr": { "xrandr": {
"on": { "prefix": " "}, "on": { "prefix": " "},
"off": { "prefix": " " } "off": { "prefix": " " },
"refresh": { "prefix": "" }
}, },
"redshift": { "redshift": {
"day": { "prefix": "" }, "day": { "prefix": "" },