Modify variables.

Change detect x11 resolution: instead of only xdpyinfo using
at first xdpyinfo, at second xorg.log, at third xorg.conf,
then cmdline and default value 1024x768.
Add writable os_x11_resolution as base for os_x11_height and
os_x11_width.
os_x11_height and os_x11_width is readonly.
develop
Mike Hiretsky 13 years ago
parent 8e35f4df56
commit 54d19def31

@ -429,21 +429,73 @@ class fillVars(varsShare):
return videoVal
return self.getVideoByDefault(list_available_drivers)
def getResByXDpyInfo(self):
"""Get resolution by xdpyinfo utility"""
lines=self._runos("xdpyinfo")
if not lines:
return ""
reRes = re.compile("dimensions:\s+(\d+)x(\d+)\s+pixels")
searchRes=False
for line in lines:
searchRes = reRes.search(line)
if searchRes:
break
if searchRes:
return "%sx%s"%(searchRes.group(1), searchRes.group(2))
return ""
def get_os_x11_resolution(self):
"""
Return current screen resolution (width, height).
Try detect by xdpyinfo, then Xorg.log, xorg.conf
"""
resolution = self.getResByXDpyInfo()
if resolution:
return resolution
if self.Get('os_root_type') != 'usb-hdd':
xlog = "/var/log/Xorg.0.log"
if os.access(xlog,os.R_OK):
reXorgLogParser = re.compile("""
Virtual\ screen\ size\ determined\ to\ be
\ ([0-9]+)\s*x\s*([0-9]+)|
Setting\ mode\ "(\d+)x(\d+)[0-9\@]"|
Output\ [\S]+\ using\ initial\ mode\ (\d+)x(\d+)|
Virtual\ size\ is\ (\d+)x(\d+)""", re.X | re.S)
resXorgLogParser = reXorgLogParser.search(open(xlog,'r').read())
if resXorgLogParser:
return "%sx%s"%filter(lambda x:x,
resXorgLogParser.groups())[:2]
# get resolution from xorg.conf
xorgconf = "/etc/X11/xorg.conf"
reScreenSections = re.compile('Section "Screen"(.*?)EndSection',
re.S)
reModes = re.compile('Modes\s+"(\d+x\d+)')
if os.access(xorgconf,os.R_OK):
sectionsScreen = filter(lambda x:"Modes" in x,
reScreenSections.findall(open('/etc/X11/xorg.conf',
'r').read()))
modes = map(lambda x:x.groups()[0],
filter(lambda x:x,
map(reModes.search, sectionsScreen)))
if modes:
return max(modes,key=lambda x:int(x.partition('x')[0]))
# get resolution from command line
reRightResolution = re.compile("^(\d+x\d+|auto)$",re.S)
kernelResolution = self.getValueFromCmdLine("calculate",3)
if kernelResolution and reRightResolution.match(kernelResolution):
return {'auto':''}.get(kernelResolution,kernelResolution)
else:
return ""
def get_os_x11_height(self):
"""Get screen height in pixeles"""
resolution = self.getX11Resolution()
if resolution:
self.Set('os_x11_width',resolution[0])
return resolution[1]
return "768"
return self.Get('os_x11_resolution').partition('x')[2] or "768"
def get_os_x11_width(self):
"""Get screen width in pixeles"""
resolution = self.getX11Resolution()
if resolution:
self.Set('os_x11_height',resolution[1])
return resolution[0]
return "1024"
return self.Get('os_x11_resolution').partition('x')[0] or "1024"
def get_os_x11_standart(self):
"""Get the nearest standard size of image relative current

@ -167,11 +167,14 @@ class Data:
# (package_name == value of cl_belong_pkg)
cl_belong_pkg = {'mode':'r', 'hide':True}
# x11 resolution (1024x768 and etc)
os_x11_resolution = {'mode':'w','hide':True}
# vertical resolution for X server
os_x11_height = {'mode':"w", 'hide':True}
os_x11_height = {'mode':"r", 'hide':True}
# horizontal resolution for X server
os_x11_width = {'mode':"w", 'hide':True}
os_x11_width = {'mode':"r", 'hide':True}
# the nearest standard size of image to current screen resolution
os_x11_standart = {'hide':True}

Loading…
Cancel
Save