GPU: Linux, count the number of GPUs
This commit is contained in:
parent
c044bd788c
commit
2284cde0d8
1 changed files with 18 additions and 1 deletions
19
fetch
19
fetch
|
@ -835,7 +835,22 @@ getcpu () {
|
|||
getgpu () {
|
||||
case "$os" in
|
||||
"Linux")
|
||||
gpu="$(lspci | grep -F "VGA")"
|
||||
# Get the GPUs
|
||||
gpu="$(lspci | grep -F "VGA" | uniq -c)"
|
||||
|
||||
# Count the number of GPUs
|
||||
count=${gpu/ ??:*}
|
||||
count=${count//[[:space:]]}
|
||||
|
||||
# If there's more than one gpu
|
||||
# Display the count.
|
||||
if [ "$count" -gt 1 ]; then
|
||||
count=" x $count"
|
||||
else
|
||||
unset count
|
||||
fi
|
||||
|
||||
# Format the output
|
||||
gpu=${gpu/* VGA compatible controller: }
|
||||
gpu=${gpu/(rev*)}
|
||||
|
||||
|
@ -923,6 +938,8 @@ getgpu () {
|
|||
gpu=${gpu// Series}
|
||||
gpu=${gpu/\/*}
|
||||
fi
|
||||
|
||||
gpu="${gpu}${count}"
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
|
Loading…
Reference in a new issue