/** * Parse a line (from xrandr's output) containing an output * * @param int $index Index * @param string $line Line to be parsed * * @return Output * @todo Exception handling */ public static function parseLine($index, $line) { trim($line); if (preg_match(Output::LINE_REGEX, $line, $result)) { return new Output($index, $result["name"], $result["connected"] == "connected" ? true : false, isset($result["primary"]) && $result["primary"] == "primary" ? true : false, isset($result["geometry"]) ? Geometry::parseString($result["geometry"]) : null, isset($result["rotation"]) && $result["rotation"] != "" ? $result["rotation"] : Rotation::NORMAL, isset($result["reflection"]) ? Reflection::parseString($result["reflection"]) : Reflection::NORMAL, isset($result["physicalWidth"]) ? $result["physicalWidth"] : 0, isset($result["physicalHeight"]) ? $result["physicalHeight"] : 0); } // ToDo: Exeption handling if (Xrandr::DEBUG) { echo "Output line could not be parsed!\n"; } return null; }