[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:
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):
self.update_widgets(widgets)
def state(self, widget):
return widget.get("state", "off")
def _refresh(self, event):
self._needs_update = True
def _toggle(self, event):
self._needs_update = True
path = os.path.dirname(os.path.abspath(__file__))

View file

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

View file

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