GPU: Linux, count the number of GPUs

This commit is contained in:
Dylan 2016-01-31 12:52:28 +11:00
parent c044bd788c
commit 2284cde0d8
1 changed files with 18 additions and 1 deletions

19
fetch
View File

@ -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}"
}
# }}}