def _get_layout(self):
        """
        Get the outputs layout from xrandr and try to detect the
        currently active layout as best as we can on start.
        """
        connected = list()
        active_layout = list()
        disconnected = list()
        layout = OrderedDict(
            {"connected": OrderedDict(), "disconnected": OrderedDict()}
        )

        current = self.py3.command_output("xrandr")
        for line in current.splitlines():
            try:
                s = line.split(" ")
                infos = line[line.find("(") :]
                if s[1] == "connected":
                    output, state, mode = s[0], s[1], None
                    for index, x in enumerate(s[2:], 2):
                        if "x" in x and "+" in x:
                            mode = x
                            active_layout.append(output)
                            infos = line[line.find(s[index + 1]) :]
                            break
                        elif "(" in x:
                            break
                    connected.append(output)
                elif s[1] == "disconnected":
                    output, state, mode = s[0], s[1], None
                    disconnected.append(output)
                else:
                    continue
            except Exception as err:
                self.py3.log('xrandr error="{}"'.format(err))
            else:
                layout[state][output] = {"infos": infos, "mode": mode, "state": state}

        # initialize the active layout
        if self.active_layout is None:
            self.active_comb = tuple(active_layout)
            self.active_layout = self._get_string_and_set_width(
                tuple(active_layout), self.active_mode
            )

        return layout
def _get_layout ( self ) : connected = list ( ) active_layout = list ( ) disconnected = list ( ) layout = OrderedDict ( { "connected" : OrderedDict ( ) , "disconnected" : OrderedDict ( ) } ) current = self . py3 . command_output ( "xrandr" ) for line in current . splitlines ( ) : try : s = line . split ( " " ) infos = line [ line . find ( "(" ) : ] if s [ 1 ] == "connected" : output , state , mode = s [ 0 ] , s [ 1 ] , None for index , x in enumerate ( s [ 2 : ] , 2 ) : if "x" in x and "+" in x : mode = x active_layout . append ( output ) infos = line [ line . find ( s [ index + 1 ] ) : ] break elif "(" in x : break connected . append ( output ) elif s [ 1 ] == "disconnected" : output , state , mode = s [ 0 ] , s [ 1 ] , None disconnected . append ( output ) else : continue except Exception as err : self . py3 . log ( 'xrandr error="{}"' . format ( err ) ) else : layout [ state ] [ output ] = { "infos" : infos , "mode" : mode , "state" : state } if self . active_layout is None : self . active_comb = tuple ( active_layout ) self . active_layout = self . _get_string_and_set_width ( tuple ( active_layout ) , self . active_mode ) return layout
Get the outputs layout from xrandr and try to detect the
        currently active layout as best as we can on start.