[xrandr] add safeguard to prevent turning off the only display

This commit is contained in:
Naya Verdier 2020-07-25 10:52:57 -07:00
parent 5874850bd5
commit b14eae4d6c
No known key found for this signature in database
GPG key ID: 1A59389D46A94A4C

View file

@ -103,7 +103,8 @@ class Module(core.module.Module):
widget = self.widget(widget_id=event["instance"]) widget = self.widget(widget_id=event["instance"])
if widget.get("state") == "on": if widget.get("state") == "on":
util.cli.execute("{} --output {} --off".format(toggle_cmd, widget.name)) if len(self._active_displays) > 1:
util.cli.execute("{} --output {} --off".format(toggle_cmd, widget.name))
elif not self._active_displays: elif not self._active_displays:
util.cli.execute("{} --output {} --auto".format(toggle_cmd, widget.name)) util.cli.execute("{} --output {} --auto".format(toggle_cmd, widget.name))
else: else: