GPU: Add caching support for all OS
This commit is contained in:
parent
7749be4156
commit
b36528dd80
1 changed files with 33 additions and 38 deletions
71
neofetch
71
neofetch
|
@ -919,53 +919,46 @@ get_cpu_usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_gpu() {
|
get_gpu() {
|
||||||
|
# Use cache if it exists
|
||||||
|
if [[ -f "${cache_dir}/neofetch/gpu" ]]; then
|
||||||
|
source "${cache_dir}/neofetch/gpu"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux" | "GNU")
|
"Linux" | "GNU")
|
||||||
# Use cache if it exists
|
gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/Display|3D|VGA/ {print $3 " " $4}')"
|
||||||
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}')"
|
|
||||||
|
|
||||||
case "$gpu" in
|
case "$gpu" in
|
||||||
*"advanced"*)
|
*"advanced"*)
|
||||||
gpu="${gpu//Intel*$'\n'}"
|
gpu="${gpu//Intel*$'\n'}"
|
||||||
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//Intel*$'\n'}"
|
gpu="${gpu//Intel*$'\n'}"
|
||||||
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
|
||||||
|
|
||||||
[[ "$gpu" =~ "intel" ]] && \
|
[[ "$gpu" =~ "intel" ]] && \
|
||||||
gpu="Intel Integrated Graphics"
|
gpu="Intel Integrated Graphics"
|
||||||
|
|
||||||
cache "gpu" "$gpu"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Mac OS X")
|
"Mac OS X")
|
||||||
# Use cache if it exists
|
gpu="$(system_profiler SPDisplaysDataType | awk -F': ' '/^\ *Chipset Model:/ {printf $2 ", "}')"
|
||||||
if [[ -f "${cache_dir}/neofetch/gpu" ]]; then
|
gpu="${gpu//'/ $'}"
|
||||||
source "${cache_dir}/neofetch/gpu"
|
gpu="${gpu%,*}"
|
||||||
else
|
|
||||||
gpu="$(system_profiler SPDisplaysDataType | awk -F': ' '/^\ *Chipset Model:/ {printf $2 ", "}')"
|
|
||||||
gpu="${gpu//'/ $'}"
|
|
||||||
gpu="${gpu%,*}"
|
|
||||||
cache "gpu" "$gpu"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"iPhone OS")
|
"iPhone OS")
|
||||||
|
@ -1030,6 +1023,8 @@ get_gpu() {
|
||||||
gpu="${gpu/NVIDIA}"
|
gpu="${gpu/NVIDIA}"
|
||||||
gpu="${gpu/Intel}"
|
gpu="${gpu/Intel}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cache "gpu" "$gpu"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_memory() {
|
get_memory() {
|
||||||
|
|
Loading…
Reference in a new issue