/** * Parsed raw xrandr output and builds lists for screens and outputs * * @throws \Exception */ public function parseRaw() { $this->screens = array(); $this->outputs = array(); $currentOutput = null; $outputIndex = 0; $raw = $this->getRaw(); if ($raw == null) { return false; } foreach ($raw as $line) { // Using switch just because I think its more "logical" selecting from a case switch (true) { // Screen case preg_match(Screen::LINE_REGEX, $line, $result): $newScreen = Screen::parseLine($line); $this->screens[$newScreen->getId()] = Screen::parseLine($line); break; // Output // Output case preg_match(Output::LINE_REGEX, $line, $result): $currentOutput = Output::parseLine($outputIndex++, $line); $this->outputs[$currentOutput->getName()] = $currentOutput; break; // Mode // Mode case preg_match(Mode::LINE_REGEX, $line, $result): if (!isset($currentOutput)) { throw new \Exception("parseRawException: Mode line but no currentOutput\n{$line}"); } $currentOutput->_addExistingMode(Mode::parseLine($line)); break; default: // ToDo: Exeption handling if (Xrandr::DEBUG) { echo "Line could not be parsed!\n"; echo $line; echo "\n"; } } } return true; }