From 059eb0eec0a1449406df1a2127b327e3ee9bcb61 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 29 Mar 2016 17:11:36 +1100 Subject: [PATCH] Don't get CPU usage if we're not going to use it --- neofetch | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index fd49d52e..20617e12 100755 --- a/neofetch +++ b/neofetch @@ -934,16 +934,17 @@ getcpu () { # Add CPU info bar prin "${subtitle}: ${cpu}" - cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')" - cpu_usage="${cpu_usage/\.*}%" + if [ "$cpu_display" != "off" ]; then + cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')" + cpu_usage="${cpu_usage/\.*}%" - case "$cpu_display" in - "info") prin "${subtitle} Usage: ${cpu_usage}" ;; - "bar") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;; - "infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;; - "barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} ))) ${cpu_usage}" ;; - "off") ;; - esac + case "$cpu_display" in + "info") prin "${subtitle} Usage: ${cpu_usage}" ;; + "bar") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;; + "infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;; + "barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} ))) ${cpu_usage}" ;; + esac + fi [ "$stdout_mode" != "on" ] && unset cpu }