[modules/xrandr] Optionally disable polling

Add option to disable display polling via xrandr to work around kernel
issues that cause persistent lags.

see #359
This commit is contained in:
Tobias Witek 2019-02-08 20:06:12 +01:00
parent 1ede937f78
commit 8511e57ed2

View file

@ -6,6 +6,8 @@ Parameters:
* xrandr.overwrite_i3config: If set to 'true', this module assembles a new i3 config * xrandr.overwrite_i3config: If set to 'true', this module assembles a new i3 config
every time a screen is enabled or disabled by taking the file "~/.config/i3/config.template" every time a screen is enabled or disabled by taking the file "~/.config/i3/config.template"
and appending a file "~/.config/i3/config.<screen name>" for every screen. and appending a file "~/.config/i3/config.<screen name>" for every screen.
* xrandr.autoupdate: If set to 'false', does *not* invoke xrandr automatically. Instead, the
module will only refresh when displays are enabled or disabled (defaults to false)
Requires the following executable: Requires the following executable:
* xrandr * xrandr
@ -25,10 +27,17 @@ class Module(bumblebee.engine.Module):
widgets = [] widgets = []
self._engine = engine self._engine = engine
super(Module, self).__init__(engine, config, widgets) super(Module, self).__init__(engine, config, widgets)
self.update_widgets(widgets) self._autoupdate = bumblebee.util.asbool(self.parameter("autoupdate", True))
self._needs_update = True
def update_widgets(self, widgets): def update_widgets(self, widgets):
new_widgets = [] new_widgets = []
if self._autoupdate == False and self._needs_update == False:
return
self._needs_update = False
for line in bumblebee.util.execute("xrandr -q").split("\n"): for line in bumblebee.util.execute("xrandr -q").split("\n"):
if not " connected" in line: if not " connected" in line:
continue continue
@ -56,6 +65,7 @@ class Module(bumblebee.engine.Module):
return widget.get("state", "off") return widget.get("state", "off")
def _toggle(self, event): def _toggle(self, event):
self._needs_update = True
path = os.path.dirname(os.path.abspath(__file__)) path = os.path.dirname(os.path.abspath(__file__))
if bumblebee.util.asbool(self.parameter("overwrite_i3config", False)) == True: if bumblebee.util.asbool(self.parameter("overwrite_i3config", False)) == True: