[modules/xrandr] Sort display widgets by position
Show display widgets from left to right according to their relative xrandr position. see #19
This commit is contained in:
parent
4ea0cfae1e
commit
c095b89022
1 changed files with 14 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
import bumblebee.module
|
import bumblebee.module
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def description():
|
def description():
|
||||||
|
@ -25,9 +26,19 @@ class Module(bumblebee.module.Module):
|
||||||
if not " connected" in line:
|
if not " connected" in line:
|
||||||
continue
|
continue
|
||||||
screen = line.split(" ", 2)[0]
|
screen = line.split(" ", 2)[0]
|
||||||
m = re.search(r'\d+x\d+\+\d+\+\d+', line)
|
m = re.search(r'\d+x\d+\+(\d+)\+\d+', line)
|
||||||
self._state = "on" if m else "off"
|
|
||||||
widgets.append(bumblebee.output.Widget(self, screen))
|
widget = bumblebee.output.Widget(self, screen)
|
||||||
|
if m:
|
||||||
|
self._state = "on"
|
||||||
|
widget.set("pos", int(m.group(1)))
|
||||||
|
else:
|
||||||
|
self._state = "off"
|
||||||
|
widget.set("pos", sys.maxint());
|
||||||
|
|
||||||
|
widgets.append(widget)
|
||||||
|
|
||||||
|
widgets.sort(key=lambda widget : widget.get("pos"))
|
||||||
|
|
||||||
return widgets
|
return widgets
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue