added handling for multiple res for multiple screens in special cases with multiple video cards

This commit is contained in:
inxi-svn 2010-10-08 06:05:34 +00:00
parent d2411ce973
commit 34876f7f9c

53
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 1.4.19
#### version: 1.4.20
#### Date: October 7 2010
########################################################################
#### SPECIAL THANKS
@ -2465,31 +2465,46 @@ get_graphics_glx_data()
get_graphics_res_data()
{
eval $LOGFS
local screen_resolution=''
local screen_resolution='' xdpy_data='' screens_count=0
if [[ $B_X_RUNNING == 'true' && $B_ROOT != 'true' ]];then
# Added the two ?'s , because the resolution is now reported without spaces around the 'x', as in
# 1400x1050 instead of 1400 x 1050. Change as of X.org version 1.3.0
screen_resolution=$( xrandr | gawk '
/\*/ {
res[++m] = gensub(/^.* ([0-9]+) ?x ?([0-9]+)[_ ].* ([0-9\.]+)\*.*$/,"\\1x\\2@\\3hz","g",$0)
}
END {
for (n in res) {
if (res[n] ~ /^[[:digit:]]+x[[:digit:]]+/) {
line = line ? line ", " res[n] : res[n]
xdpy_data="$( xdpyinfo )"
xdpy_count=$( grep -c 'dimensions' <<< "$xdpy_data" )
# we get a bit more info from xrandr than xdpyinfo, but xrandr fails to handle
# multiple screens from different video cards
if [[ $xdpy_count -eq 1 ]];then
screen_resolution=$( xrandr | gawk '
/\*/ {
res[++m] = gensub(/^.* ([0-9]+) ?x ?([0-9]+)[_ ].* ([0-9\.]+)\*.*$/,"\\1x\\2@\\3hz","g",$0)
}
END {
for (n in res) {
if (res[n] ~ /^[[:digit:]]+x[[:digit:]]+/) {
line = line ? line ", " res[n] : res[n]
}
}
if (line) {
print(line)
}
}
if (line) {
print(line)
}
}' )
if [[ -z $screen_resolution ]];then
screen_resolution=$( xdpyinfo | gawk '
/dimensions/ {
print $2
}' )
fi
if [[ -z $screen_resolution || $xdpy_count -gt 1 ]];then
screen_resolution=$( gawk '
BEGIN {
IGNORECASE=1
screens = ""
separator = ""
}
/dimensions/ {
screens = screens $2 separator
separator = ", "
}
END {
print screens
}' <<< "$xdpy_data" )
fi
else
screen_resolution=$( stty -F $( readlink /proc/$PPID/fd/0 ) size | gawk '{
print $2"x"$1