From ab09bf9670648765a44c48e4bf95d8030913e611 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 30 Mar 2016 14:00:13 +1100 Subject: [PATCH] Implement cache function and add caching for GPU --- neofetch | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/neofetch b/neofetch index 94afddc8..05adb5b1 100755 --- a/neofetch +++ b/neofetch @@ -949,6 +949,12 @@ getcpu () { # GPU {{{ getgpu () { + # Use cache if it exists + if [ -f "/tmp/neofetch/gpu" ]; then + source "/tmp/neofetch/gpu" + return + fi + case "$os" in "Linux") gpu="$(PATH="/sbin:$PATH" lspci | grep -F "3D")" @@ -1069,6 +1075,9 @@ getgpu () { gpu=${gpu//+( )/ } 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/*-}" +} + +# }}} # }}}