getInfo 2.49.0

This commit is contained in:
kyodev 2017-11-29 18:20:36 +01:00
parent 733a5ac232
commit 749f7daeaa
3 changed files with 98 additions and 113 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.48.1
date="28/11/2017"
version=2.49.0
date="29/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -532,45 +532,18 @@ toDisplay=(
echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
}
# $1 chaines à extraire (sur un grep -Ei), $2 objet raw|name
f_lspci(){ # 28/11/2017
local slots lspci display=''
# uniquement le name du device
if [ "$2" == "name" ]; then
while read field1 lspci; do
lspci=${lspci#*: } # lspci==Intel Corporation System Controller ...
lspci=${lspci% (rev*} # suppression à la fin
lspci=${lspci/Corporation } # suppression ' Corporation'
lspci=${lspci/Advanced Micro Devices, Inc. } # suppression 'Advanced Micro Devices, Inc. '
display+="$lspci"$'\n'
done <<< $( lspci | grep -Ei "$1" )
# lspci détaillé
elif [ "$2" == "raw" ]; then
slots=$( lspci | grep -Ei "$1" | cut -d" " -f1 )
if ! lspci -nnv &>/dev/null ; then # commande/option indisponible
display+="lspci -nnv -s <device> non disponible"
else
for lspci in $slots; do
display+=$( lspci -nnv -s "$lspci" )$'\n\n'
done
fi
fi
display=${display%[[:cntrl:]]} # suppression \nl finaux
echo -en "$display\n"
}
fi_audio(){ # 28/11/2017
local audio nb_audio cardsAudio cmd_cards version_alsa card_alsa mod modules text
local alert_alsa
# liste des devices
audio=$( f_lspci "Audio device|Audio controller|Multimedia audio controller" "name" )
audio=$( fi_lspci "Audio device|Audio controller|Multimedia audio controller" "name" )
# qte de devices
nb_audio=$(f__wcv -l "$audio")
# lspci
cardsAudio=$( f_lspci "Audio device|Audio controller|Multimedia audio controller" "raw" )
cardsAudio=$( fi_lspci "Audio device|Audio controller|Multimedia audio controller" "raw" )
cmd_cards="lspci -nnv | grep -EiA6 'Audio device|Audio controller'"
# version ALSA
@ -843,71 +816,30 @@ fi_efi(){ # 20/11/2017
unset text
}
fi_graph(){ # 28/11/2017
local slots cards cmd_cards ig
fi_graph(){ # 29/11/2017
local cards cmd_cards
local stck_glxinfo stck_glxinfoOpt stck_glxinfoDri glx_dvc cmd_glx_dvc glx_dvc_temp openGl cmd_openGl
local providers resolutions pluriel modules cmt_modules text
local alert_hybrid alert_3D alert_Wayland
# cardsManuel="$(lspci -nnk | grep -EiA 3 'vga|display|3d')" # -nn: textual and numeric ID's, k kernel
# cardsManuel="$(lspci -nnv | grep -iEA11 'vga|display|3d)" # v=verbose
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1 )" si plusieurs devices possibles??
# cardsManuel="$(lspci -nnv | grep -iEA10 'vga|display|3d)" # v=verbose
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1 )"
# cardsManuel="lspci -nnv -s $(gawk '/VGA |Display |3D / {print $1}' <<< $( lspci ))"
[ "$fg_nb_gpu" ] || figet_gpu
[ "$fg_nb_gpu" -eq 0 ] && return 0 # pas de gpu, rien à voir
# slots pci video
slots="$(lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1)"
# lspci
cmd_cards="lspci -nnv | grep -EiA11 'VGA .* controller|Display controller|3D controller'" # commande par défaut
if ! lspci -nnv &>/dev/null ; then # commande/option indisponible
cards="lspci -nnv non disponible"$'\n'
elif [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, essai optirun ou prime
if [ $( f__which optirun ) ]; then
for ig in $slots; do
cards+=$( optirun lspci -nnv -s $ig )$'\n'
done
cmd_cards="optirun $cmd_cards"
else # DRI
for ig in $slots; do
cards+=$( DRI_PRIME=1 lspci -nnv -s $ig )$'\n'
done
cmd_cards="DRI_PRIME=1 cmd_cards"
fi
else
cards+=$( lspci -nnv -s $slots )$'\n' # une seule carte
cmd_cards="lspci -nnv -s $(gawk '/VGA |Display |3D / {print $1}' <<< $( lspci ))"
if [ "$fg_nb_gpu" -eq 1 ]; then # une seule carte
cards=$( fi_lspci "VGA .* controller|Display controller|3D controller|Graphic|multimedia" "raw" )
else # plusieurs cartes, essai optirun ou prime
cards=$( fi_lspci "VGA .* controller|Display controller|3D controller|Graphic|multimedia" "raw" "graph")
prefixCmd=$(basename $(which toto) 2>/dev/null) || prefixCmd="DRI_PRIME=1"
cmd_cards="$prefixCmd $cmd_cards"
fi
cards=${cards//(prog-if*])} #suppression (prog-if...])
[ "$cards" ] && cards=${cards::-1} # suppression dernier $'\n'
if grep -iq 'Unknown header type 7f' <<< "$cards" ; then
alert_hybrid="Une carte graphique semble désactivée actuellement, lspci n'est pas complet. \n"
alert_hybrid+="Voir DRI_PRIME, vga-switcheroo, Bumbledee...?"
fi
# $1="[opt|dri]", assigne $openGl pour un ou plusieurs gpu (dri & optirun) & $cmd_openGl
fi_graph_openGl(){
local iogl dri_glxinfo=""
[[ "$1" == "opt" ]] && openGl+="\n---- \n"
toScrut=(
'OpenGL vendor'
'OpenGL renderer'
'OpenGL version'
'shading language'
'OpenGL extensions'
)
for iogl in "${toScrut[@]}" ; do
if [ "$1" == "dri" ]; then
dri_glxinfo+=$( grep "$iogl" <<< $stck_glxinfoDri )$'\n'
elif [ "$1" == "opt" ]; then
openGl+=$( grep "$iogl" <<< $stck_glxinfoOpt )$'\n'
else
openGl+=$( grep "$iogl" <<< "$stck_glxinfo" )$'\n'
fi
done
if [ "$1" == "dri" ]; then
dri_glxinfo=${dri_glxinfo::-1}
[ $( f__which uniq ) ] && openGl=$( uniq <<< $dri_glxinfo ) || openGl="$dri_glxinfo"
fi
openGl=${openGl::-1}
}
if [[ "$wayland" && "$EUID" -eq 0 ]]; then # évite erreur $DISPLAY en root wayland
openGl="n/a:wayland root"
resolutions="n/a:wayland root"
@ -993,16 +925,38 @@ fi_graph(){ # 28/11/2017
# résolutions possibles, pas d'affichage si mode (ssh) ou xrandr pas accessible
f_display "resolutions" "cmd" "$cmd_resolutions" "$cmt_resolutions"
# modules vidéo
if [ "$modules" ]; then
f_display "modules" "var" "modules vidéo" "$cmt_modules"
else
text+="Modules non reconnus. Il serait bien de communiquer le retour de \`lsmod\` \n"
text+="merci de contacter $projet: \n$contact "
fi
f_display "modules" "var" "modules vidéo" "$cmt_modules"
echo -en "$text\n" >> "$fileOutput"
unset text
}
# $1="[opt|dri]", assigne $openGl pour un ou plusieurs gpu (dri & optirun) & $cmd_openGl
fi_graph_openGl(){ # 28/11/2017
local iogl dri_glxinfo=""
[[ "$1" == "opt" ]] && openGl+="\n---- \n"
toScrut=(
'OpenGL vendor'
'OpenGL renderer'
'OpenGL version'
'shading language'
'OpenGL extensions'
)
for iogl in "${toScrut[@]}" ; do
if [ "$1" == "dri" ]; then
dri_glxinfo+=$( grep "$iogl" <<< $stck_glxinfoDri )$'\n'
elif [ "$1" == "opt" ]; then
openGl+=$( grep "$iogl" <<< $stck_glxinfoOpt )$'\n'
else
openGl+=$( grep "$iogl" <<< "$stck_glxinfo" )$'\n'
fi
done
if [ "$1" == "dri" ]; then
dri_glxinfo=${dri_glxinfo::-1}
[ $( f__which uniq ) ] && openGl=$( uniq <<< $dri_glxinfo ) || openGl="$dri_glxinfo"
fi
openGl=${openGl::-1}
}
fi_hw(){ # 25/11/2017
[ "$fg_hw" ] || figet_hw
###
@ -1215,6 +1169,46 @@ fi_log_xorg(){ # 27/11/2017
unset text
}
# $1 chaines à extraire (sur un grep -Ei), $2 objet raw|name, $3=[graph] (optirun, DRI)
fi_lspci(){ # 29/11/2017
local slots lspci display='' prefixCmd
# uniquement les devices
if [ "$2" == "name" ]; then
while read field1 lspci; do
lspci=${lspci#*: } # suppression début, jusqu"à': '
lspci=${lspci% (rev*} # suppression à la fin, '(rev..'
lspci=${lspci/System Controller Hub } # suppression ' Corporation'
lspci=${lspci/Corporation } # suppression ' Corporation'
lspci=${lspci/Advanced Micro Devices, Inc. } # suppression 'Advanced Micro Devices, Inc. '
display+="$lspci"$'\n'
done <<< $( lspci | grep -Ei "$1" )
# lspci détaillé
elif [ "$2" == "raw" ]; then
slots=$( lspci | grep -Ei "$1" | cut -d" " -f1 )
if ! lspci -nnv &>/dev/null ; then # commande/option indisponible
display="lspci -nnv -s <device> non disponible"
else
for lspci in $slots; do
if [[ "$3" == "graph" && "$( f__which optirun )" ]]; then
lspci=$( optirun lspci -nnv -s $lspci )
elif [ "$3" == "graph" ]; then
lspci=$( DRI_PRIME=1 lspci -nnv -s $lspci )
else
lspci=$( lspci -nnv -s $lspci ) # normalement inutile, le contexte DRI_PRIME pourrait marcher partout
fi
lspci=${lspci/(prog-if*])} # suppression (prog-if...])
lspci=${lspci/Capabilities: <access denied>[[:cntrl:]][[:blank:]]} # suppression Capabilities: <access denied> (user)
display+="$lspci"$'\n\n' # double \n pour espace entre card
done
fi
fi
display=${display%[[:cntrl:]]} # suppression \nl finaux
echo -en "$display\n"
}
fi_mem(){ # 20/11/2017
local memoire swappiness text
figet_mem "mem" #options possibles mem swap total notitle nocoltitle
@ -1624,11 +1618,11 @@ fi_reseau(){ # 28/11/2017
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'network|ethernet' | cut -d" " -f1 )" si devices plusieurs slots???
#lspci
# liste des devices
reseau=$( f_lspci "Ethernet controller|Network controller" "name" )
reseau=$( fi_lspci "Ethernet controller|Network controller" "name" )
# nombre de devices
nb_reseau=$(f__wcv -l "$reseau")
# lspci
cards=$( f_lspci "Ethernet controller|Network controller" "raw" )
cards=$( fi_lspci "Ethernet controller|Network controller" "raw" )
cmd_cards="lspci -nnv | grep -EiA 15 'network|ethernet'"
# ip a & route
ip_a=$( ip a | sed '/link\/ether/d; /valid_lft/d' ) # filtre sur adr MAC & bail
@ -2788,26 +2782,12 @@ figet_dmi(){ #v2 06/11/2017
[ "$bios" ] && fg_dmi+=$(printf "%s : %s" "bios" "$bios")
}
# assigne $fg_gpu (liste des gpu), $fg_nb_gpu
figet_gpu(){ #v3 27/11/2017
local lspci field1
lspci="$(lspci -mm 2>/dev/null)"
if [ "$?" -eq 0 ]; then
# debug: lspci="$(< tests/lspci)"
fg_gpu="$(gawk -F' "|" "|" -' ' /"Display|"3D|"VGA/ {
sub(/ Corporation/,"",$3); sub(/Advanced Micro Devices, Inc. /,"",$3); sub(/ /," ",$3);
print $3": "$4}' <<< $lspci)"
else # lspci -mm en erreur, utilisation lspci (dans les requis)
while read field1 lspci; do
fg_gpu+="$lspci"$'\n'
done <<< $( lspci | grep -Ei 'Display |3D |VGA ' )
fg_gpu=${fg_gpu#*: } # lspci==Intel Corporation System Controller ...
fg_gpu=${fg_gpu% (rev*} # remplacement espace double par simple
fg_gpu=${fg_gpu/Corporation } # suppression ' Corporation'
fg_gpu=${fg_gpu/Advanced Micro Devices, Inc. } # suppression 'Advanced Micro Devices, Inc. '
fg_audio=${fg_audio%[[:cntrl:]]} # suppression derniers $'\n'
fi
fg_nb_gpu=$(f__wcv -l "$fg_gpu")
# assigne $fg_gpu (liste des gpu), $fg_nb_gpu, requiert fi_lspci()
figet_gpu(){ #v4 29/11/2017
# laissé en fonction car utilisé par fi_system & fi_graph
# tout se passe dans fi_lspci
fg_gpu=$( fi_lspci "VGA .* controller|Display controller|3D controller|Graphic|multimedia" "name")
fg_nb_gpu=$( f__wcv "-l" "$fg_gpu" )
}
# infos température et fan via acpi, assigne $fg_hw
@ -3688,6 +3668,7 @@ for j in $options; do
prg_1 "$*"
echo -n "•"
fi_audio
fi_graph
exit ;; # test
-c* | all )
[ "$j" == "-c" ] && exec $0 "menu"

View File

@ -5,9 +5,13 @@
## 2.49.0 29/11/2017
*révision: fi-graph, figet_gpu, utilisation f_lspci
## 2.48.1 28/11/2017
* nouveau: début audio: fi_audio
* nouveau: fi_audio
* nouveau: f_lspci
* révision: fi_reseau, utilisation f_lspci