From 0674f141256e3395e6c1ebf436a60669f2427a57 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 13:10:08 +1100 Subject: [PATCH 1/2] Cache: Simplify caching --- neofetch | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/neofetch b/neofetch index 8f26ef8a..3cea006a 100755 --- a/neofetch +++ b/neofetch @@ -976,10 +976,16 @@ get_gpu() { ;; "Mac OS X") - gpu="$(system_profiler SPDisplaysDataType | awk -F': ' '/^\ *Chipset Model:/ {printf $2 ", "}')" - gpu="${gpu//'/ $'}" - gpu="${gpu%,*}" - cache "gpu" "$gpu" + if [[ -f "${cache_dir}/neofetch" ]]; 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 ;; "iPhone OS") @@ -2426,13 +2432,8 @@ info() { # $1 is the subtitle subtitle="$1" - # Use cache if it exists - if [[ -f "${cache_dir}/neofetch/${2}" ]]; then - source "${cache_dir}/neofetch/${2}" - else - # Call the function. - "get_${2:-$1}" 2>/dev/null - fi + # Call the function. + "get_${2:-$1}" 2>/dev/null # Update the variable output="${2:-$1}" From d08fdbf0e3a0fd3be1f81ef12c90c3d2c239fa2f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 13:14:36 +1100 Subject: [PATCH 2/2] Fix test --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 3cea006a..c9271f09 100755 --- a/neofetch +++ b/neofetch @@ -976,7 +976,7 @@ get_gpu() { ;; "Mac OS X") - if [[ -f "${cache_dir}/neofetch" ]]; then + if [[ -f "${cache_dir}/neofetch/gpu" ]]; then source "${cache_dir}/neofetch/gpu" else