diff --git a/neofetch b/neofetch index 178b6795..041a090b 100755 --- a/neofetch +++ b/neofetch @@ -919,53 +919,46 @@ get_cpu_usage() { } get_gpu() { + # Use cache if it exists + if [[ -f "${cache_dir}/neofetch/gpu" ]]; then + source "${cache_dir}/neofetch/gpu" + return + fi + case "$os" in "Linux" | "GNU") - # Use cache if it exists - if [[ -f "/tmp/neofetch/gpu" ]]; then - source "/tmp/neofetch/gpu" - else - gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/Display|3D|VGA/ {print $3 " " $4}')" + gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/Display|3D|VGA/ {print $3 " " $4}')" - case "$gpu" in - *"advanced"*) - gpu="${gpu//Intel*$'\n'}" - gpu="${gpu/'[AMD/ATI]' }" - gpu="${gpu/'[AMD]' }" - gpu="${gpu/*\[}" - gpu="${gpu/\]*}" - gpu="AMD $gpu" - ;; + case "$gpu" in + *"advanced"*) + gpu="${gpu//Intel*$'\n'}" + gpu="${gpu/'[AMD/ATI]' }" + gpu="${gpu/'[AMD]' }" + gpu="${gpu/*\[}" + gpu="${gpu/\]*}" + gpu="AMD $gpu" + ;; - *"nvidia"*) - gpu="${gpu//Intel*$'\n'}" - gpu="${gpu/*\[}" - gpu="${gpu/\]*}" - gpu="NVIDIA $gpu" - ;; + *"nvidia"*) + gpu="${gpu//Intel*$'\n'}" + gpu="${gpu/*\[}" + gpu="${gpu/\]*}" + gpu="NVIDIA $gpu" + ;; - *"virtualbox"*) - gpu="VirtualBox Graphics Adapter" - ;; - esac + *"virtualbox"*) + gpu="VirtualBox Graphics Adapter" + ;; + esac - [[ "$gpu" =~ "intel" ]] && \ - gpu="Intel Integrated Graphics" - - cache "gpu" "$gpu" - fi + [[ "$gpu" =~ "intel" ]] && \ + gpu="Intel Integrated Graphics" ;; "Mac OS X") - # Use cache if it exists - if [[ -f "${cache_dir}/neofetch/gpu" ]]; then - source "${cache_dir}/neofetch/gpu" - else - gpu="$(system_profiler SPDisplaysDataType | awk -F': ' '/^\ *Chipset Model:/ {printf $2 ", "}')" - gpu="${gpu//'/ $'}" - gpu="${gpu%,*}" - cache "gpu" "$gpu" - fi + gpu="$(system_profiler SPDisplaysDataType | awk -F': ' '/^\ *Chipset Model:/ {printf $2 ", "}')" + gpu="${gpu//'/ $'}" + gpu="${gpu%,*}" ;; "iPhone OS") @@ -1030,6 +1023,8 @@ get_gpu() { gpu="${gpu/NVIDIA}" gpu="${gpu/Intel}" fi + + cache "gpu" "$gpu" } get_memory() {