mirror of
https://github.com/dylanaraps/neofetch.git
synced 2025-12-23 03:59:58 +00:00
Implement cache function and add caching for GPU
This commit is contained in:
17
neofetch
17
neofetch
@@ -949,6 +949,12 @@ getcpu () {
|
|||||||
# GPU {{{
|
# GPU {{{
|
||||||
|
|
||||||
getgpu () {
|
getgpu () {
|
||||||
|
# Use cache if it exists
|
||||||
|
if [ -f "/tmp/neofetch/gpu" ]; then
|
||||||
|
source "/tmp/neofetch/gpu"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux")
|
"Linux")
|
||||||
gpu="$(PATH="/sbin:$PATH" lspci | grep -F "3D")"
|
gpu="$(PATH="/sbin:$PATH" lspci | grep -F "3D")"
|
||||||
@@ -1069,6 +1075,9 @@ getgpu () {
|
|||||||
|
|
||||||
gpu=${gpu//+( )/ }
|
gpu=${gpu//+( )/ }
|
||||||
gpu="${gpu}${count}"
|
gpu="${gpu}${count}"
|
||||||
|
|
||||||
|
# Cache the output
|
||||||
|
cache "gpu" "$gpu"
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
@@ -2449,6 +2458,14 @@ bar() {
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
# Cache {{{
|
||||||
|
|
||||||
|
cache () {
|
||||||
|
mkdir -p "/tmp/neofetch"
|
||||||
|
echo "${1/*-}=\"$2\"" > "/tmp/neofetch/${1/*-}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user