@ -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 " %s x %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 " %s x %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