/** * Parse a line (from xrandr's output) containing a screen * * @param string $line Line to be parsed * * @return Screen */ public static function parseLine($line) { trim($line); if (preg_match(Screen::LINE_REGEX, $line, $result)) { return new Screen($result["id"], Geometry::parseString($result["minimumGeometry"]), Geometry::parseString($result["currentGeometry"]), Geometry::parseString($result["maximumGeometry"])); } // ToDo: Exeption handling if (Xrandr::DEBUG) { echo "Screen line could not be parsed!\n"; } return null; }
/** * Parse the name as geometry string and return resulting Geometry * * @return Geometry */ public function getProbableResolution() { return Geometry::parseString($this->name); }
/** * 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; }