[modules/xrandr] Change quotation
This commit is contained in:
parent
59dc5f8047
commit
932d362d30
1 changed files with 26 additions and 26 deletions
|
@ -1,11 +1,11 @@
|
||||||
# pylint: disable=C0111,R0903
|
# pylint: disable=C0111,R0903
|
||||||
|
|
||||||
"""Shows a widget for each connected screen and allows the user to enable/disable screens.
|
'''Shows a widget for each connected screen and allows the user to enable/disable screens.
|
||||||
|
|
||||||
Parameters:
|
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
|
* 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 true)
|
module will only refresh when displays are enabled or disabled (defaults to true)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ Requires the following python module:
|
||||||
|
|
||||||
Requires the following executable:
|
Requires the following executable:
|
||||||
* xrandr
|
* xrandr
|
||||||
"""
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -35,11 +35,11 @@ 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._autoupdate = bumblebee.util.asbool(self.parameter("autoupdate", True))
|
self._autoupdate = bumblebee.util.asbool(self.parameter('autoupdate', True))
|
||||||
self._needs_update = True
|
self._needs_update = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
i3.Subscription(self._output_update, "output")
|
i3.Subscription(self._output_update, 'output')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ class Module(bumblebee.engine.Module):
|
||||||
|
|
||||||
self._needs_update = False
|
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
|
||||||
display = line.split(" ", 2)[0]
|
display = line.split(' ', 2)[0]
|
||||||
m = re.search(r'\d+x\d+\+(\d+)\+\d+', line)
|
m = re.search(r'\d+x\d+\+(\d+)\+\d+', line)
|
||||||
|
|
||||||
widget = self.widget(display)
|
widget = self.widget(display)
|
||||||
|
@ -66,8 +66,8 @@ class Module(bumblebee.engine.Module):
|
||||||
self._engine.input.register_callback(widget, button=1, cmd=self._toggle)
|
self._engine.input.register_callback(widget, button=1, cmd=self._toggle)
|
||||||
self._engine.input.register_callback(widget, button=3, cmd=self._toggle)
|
self._engine.input.register_callback(widget, button=3, cmd=self._toggle)
|
||||||
new_widgets.append(widget)
|
new_widgets.append(widget)
|
||||||
widget.set("state", "on" if m else "off")
|
widget.set('state', 'on' if m else 'off')
|
||||||
widget.set("pos", int(m.group(1)) if m else sys.maxsize)
|
widget.set('pos', int(m.group(1)) if m else sys.maxsize)
|
||||||
|
|
||||||
while len(widgets) > 0:
|
while len(widgets) > 0:
|
||||||
del widgets[0]
|
del widgets[0]
|
||||||
|
@ -75,8 +75,8 @@ class Module(bumblebee.engine.Module):
|
||||||
widgets.append(widget)
|
widgets.append(widget)
|
||||||
|
|
||||||
if self._autoupdate == False:
|
if self._autoupdate == False:
|
||||||
widget = bumblebee.output.Widget(full_text="")
|
widget = bumblebee.output.Widget(full_text='')
|
||||||
widget.set("state", "refresh")
|
widget.set('state', 'refresh')
|
||||||
self._engine.input.register_callback(widget, button=1, cmd=self._refresh)
|
self._engine.input.register_callback(widget, button=1, cmd=self._refresh)
|
||||||
widgets.append(widget)
|
widgets.append(widget)
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class Module(bumblebee.engine.Module):
|
||||||
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):
|
def _refresh(self, event):
|
||||||
self._needs_update = True
|
self._needs_update = True
|
||||||
|
@ -93,26 +93,26 @@ class Module(bumblebee.engine.Module):
|
||||||
self._needs_update = True
|
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:
|
||||||
toggle_cmd = "{}/../../bin/toggle-display.sh".format(path)
|
toggle_cmd = '{}/../../bin/toggle-display.sh'.format(path)
|
||||||
else:
|
else:
|
||||||
toggle_cmd = "xrandr"
|
toggle_cmd = 'xrandr'
|
||||||
|
|
||||||
widget = self.widget_by_id(event["instance"])
|
widget = self.widget_by_id(event['instance'])
|
||||||
|
|
||||||
if widget.get("state") == "on":
|
if widget.get('state') == 'on':
|
||||||
bumblebee.util.execute("{} --output {} --off".format(toggle_cmd, widget.name))
|
bumblebee.util.execute('{} --output {} --off'.format(toggle_cmd, widget.name))
|
||||||
else:
|
else:
|
||||||
first_neighbor = next((widget for widget in self.widgets() if widget.get("state") == "on"), None)
|
first_neighbor = next((widget for widget in self.widgets() if widget.get('state') == 'on'), None)
|
||||||
last_neighbor = next((widget for widget in reversed(self.widgets()) if widget.get("state") == "on"), None)
|
last_neighbor = next((widget for widget in reversed(self.widgets()) if widget.get('state') == 'on'), None)
|
||||||
|
|
||||||
neighbor = first_neighbor if event["button"] == bumblebee.input.LEFT_MOUSE else last_neighbor
|
neighbor = first_neighbor if event['button'] == bumblebee.input.LEFT_MOUSE else last_neighbor
|
||||||
|
|
||||||
if neighbor is None:
|
if neighbor is None:
|
||||||
bumblebee.util.execute("{} --output {} --auto".format(toggle_cmd, widget.name))
|
bumblebee.util.execute('{} --output {} --auto'.format(toggle_cmd, widget.name))
|
||||||
else:
|
else:
|
||||||
bumblebee.util.execute("{} --output {} --auto --{}-of {}".format(toggle_cmd, widget.name,
|
bumblebee.util.execute('{} --output {} --auto --{}-of {}'.format(toggle_cmd, widget.name,
|
||||||
"left" if event.get("button") == bumblebee.input.LEFT_MOUSE else "right",
|
'left' if event.get('button') == bumblebee.input.LEFT_MOUSE else 'right',
|
||||||
neighbor.name))
|
neighbor.name))
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue