Cache GPU output

This commit is contained in:
Dylan Araps 2016-10-26 23:22:08 +11:00
parent b2d17711f9
commit 4e7955bc94
1 changed files with 25 additions and 19 deletions

View File

@ -987,29 +987,35 @@ getcpu_usage() {
getgpu() { getgpu() {
case "$os" in case "$os" in
"Linux") "Linux")
gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/3D|VGA/ {print $3 " " $4}')" # Use cache if it exists
if [ -f "/tmp/neofetch/gpu" ]; then
source "/tmp/neofetch/gpu"
else
gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/3D|VGA/ {print $3 " " $4}')"
case "$gpu" in case "$gpu" in
intel*) gpu="Intel Integrated Graphics" ;; intel*) gpu="Intel Integrated Graphics" ;;
advanced*) advanced*)
gpu="${gpu/'[AMD/ATI]' }" gpu="${gpu/'[AMD/ATI]' }"
gpu="${gpu/'[AMD]' }" gpu="${gpu/'[AMD]' }"
gpu="${gpu/*\[}" gpu="${gpu/*\[}"
gpu="${gpu/\]*}" gpu="${gpu/\]*}"
gpu="AMD $gpu" gpu="AMD $gpu"
;; ;;
nvidia*) nvidia*)
gpu="${gpu/*\[}" gpu="${gpu/*\[}"
gpu="${gpu/\]*}" gpu="${gpu/\]*}"
gpu="NVIDIA $gpu" gpu="NVIDIA $gpu"
;; ;;
*virtualbox*) *virtualbox*)
gpu="VirtualBox Graphics Adapter" gpu="VirtualBox Graphics Adapter"
;; ;;
esac esac
cache "gpu" "$gpu" "/tmp"
fi
;; ;;
"Mac OS X") "Mac OS X")