public static function __startup() { /* // Right now Phodevi is just using xrandr to set display modes, so if that's not present, this module will be useless if(!pts_client::executable_in_path('xrandr')) { return pts_module::MODULE_UNLOAD; } */ if (count(phodevi_parser::read_xdpy_monitor_info()) > 1) { // No multi-monitor support right now return pts_module::MODULE_UNLOAD; } }
public static function monitor_modes() { // Determine resolutions for each monitor $resolutions = array(); if (phodevi::read_property('monitor', 'count') == 1) { array_push($resolutions, phodevi::read_property('gpu', 'screen-resolution-string')); } else { foreach (phodevi_parser::read_xdpy_monitor_info() as $monitor_line) { $this_resolution = substr($monitor_line, strpos($monitor_line, ':') + 2); $this_resolution = substr($this_resolution, 0, strpos($this_resolution, ' ')); array_push($resolutions, $this_resolution); } } return implode(',', $resolutions); }
public static function gpu_screen_resolution() { $resolution = false; if (($default_mode = getenv('DEFAULT_VIDEO_MODE')) != false) { $default_mode = explode('x', $default_mode); if (count($default_mode) == 2 && is_numeric($default_mode[0]) && is_numeric($default_mode[1])) { return $default_mode; } } if (phodevi::is_macosx()) { $info = pts_strings::trim_explode(' ', phodevi_osx_parser::read_osx_system_profiler('SPDisplaysDataType', 'Resolution')); $resolution = array(); $resolution[0] = $info[0]; $resolution[1] = $info[2]; } else { if (phodevi::is_linux() || phodevi::is_bsd() || phodevi::is_solaris()) { if ($resolution == false && pts_client::executable_in_path('xrandr')) { $resolution = self::gpu_xrandr_resolution(); } if ($resolution == false && phodevi::is_linux()) { // Before calling xrandr first try to get the resolution through KMS path foreach (pts_file_io::glob('/sys/class/drm/card*/*/modes') as $connector_path) { $connector_path = dirname($connector_path) . '/'; if (is_file($connector_path . 'enabled') && pts_file_io::file_get_contents($connector_path . 'enabled') == 'enabled') { $mode = pts_arrays::first_element(explode("\n", pts_file_io::file_get_contents($connector_path . 'modes'))); $info = pts_strings::trim_explode('x', $mode); if (count($info) == 2) { $resolution = $info; break; } } } } if ($resolution == false && phodevi::is_nvidia_graphics()) { // Way to find resolution through NVIDIA's NV-CONTROL extension // But rely upon xrandr first since when using NVIDIA TwinView the reported FrontEndResolution may be the smaller of the two if (($frontend_res = phodevi_parser::read_nvidia_extension('FrontendResolution')) != false) { $resolution = pts_strings::comma_explode($frontend_res); } } if ($resolution == false) { // Fallback to reading resolution from xdpyinfo foreach (phodevi_parser::read_xdpy_monitor_info() as $monitor_line) { $this_resolution = substr($monitor_line, strpos($monitor_line, ': ') + 2); $this_resolution = substr($this_resolution, 0, strpos($this_resolution, ' ')); $this_resolution = explode('x', $this_resolution); if (count($this_resolution) == 2 && is_numeric($this_resolution[0]) && is_numeric($this_resolution[1])) { $resolution = $this_resolution; break; } } } if ($resolution == false && is_readable('/sys/class/graphics/fb0/virtual_size')) { // As last fall-back try reading size of fb $virtual_size = explode(',', pts_file_io::file_get_contents('/sys/class/graphics/fb0/virtual_size')); if (count($virtual_size) == 2 && is_numeric($virtual_size[0]) && is_numeric($virtual_size[1])) { $resolution = $virtual_size; } } } } return $resolution == false ? array(-1, -1) : $resolution; }