From 8cce81c47ef51616078b6f708cbdde116f4fe0da Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sat, 12 Mar 2016 23:01:20 +1100 Subject: [PATCH 1/5] made cpu_bar easier to use --- neofetch | 55 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/neofetch b/neofetch index f814055f..babdae1c 100755 --- a/neofetch +++ b/neofetch @@ -881,6 +881,46 @@ getcpu () { cpu=${cpu// Six-Core} cpu=${cpu// Eight-Core} cpu=${cpu// with Radeon HD Graphics} + + # Make the output of cpu shorter + case "$cpu_shorthand" in + "name") + cpu=${cpu/@*} + ;; + + "speed") + cpu=${cpu#*@ } + ;; + + "on" | "tiny") + cpu=${cpu/Intel } + cpu=${cpu/Core } + cpu=${cpu/Core? Duo } + cpu=${cpu/AMD } + + case "$cpu_shorthand" in + "tiny") cpu=${cpu/@*} ;; + esac + ;; + esac + + # Add CPU info bar + case "$cpu_info_bar" in + "info" | "bar" | "infobar" | "barinfo") + prin "CPU: ${cpu}" + + cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')" + cpu_usage="${cpu_usage/\.*}%" + + case "$cpu_info_bar" in + "info") prin "CPU Usage: ${cpu_usage}" ;; + "bar") prin "CPU Usage: $(bar "${cpu_usage/'%'}" 100)" ;; + "infobar") prin "CPU Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" 100)" ;; + "barinfo") prin "CPU Usage: $(bar "${cpu_usage/'%'}" 100) ${cpu_usage}" ;; + esac + + unset cpu + esac } # }}} @@ -2521,14 +2561,13 @@ while [ "$1" ]; do progress_color_elapsed="$2" progress_color_total="$3" ;; - --cpu_usage_bar) cpu_usage_bar="$2" ;; - --memory_bar) memory_bar="$2" ;; - --battery_bar) battery_bar="$2" ;; - --disk_bar) disk_bar="$2" ;; - --cpu_usage_info) cpu_usage_info="$2" ;; - --memory_info) memory_info="$2" ;; - --battery_info) battery_info="$2" ;; - --disk_info) disk_info="$2" ;; + --cpu_display) + cpu_shorthand="$2" + cpu_info_bar="$3" + ;; + --memory_info_bar) memory_info_bar="$2" ;; + --battery_info_bar) battery_info_bar="$2" ;; + --disk_info_bar) disk_info_bar="$2" ;; # Image --image) From 78e78a08f2e9998251f906ff707ffeb84a2cb8ce Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sat, 12 Mar 2016 23:43:16 +1100 Subject: [PATCH 2/5] made disk_bar easier to use --- neofetch | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/neofetch b/neofetch index babdae1c..b342d257 100755 --- a/neofetch +++ b/neofetch @@ -1438,17 +1438,22 @@ getdisk () { # Put it all together disk="${disk_used} / ${disk_total} (${disk_total_per})" - if [ "$disk_bar" == "on" ]; then - disk_used=${disk_used/G} - disk_used=${disk_used/T} - disk_total=${disk_total/G} - disk_total=${disk_total/T} + # Add info bar + case "$disk_info_bar" in + "bar" | "infobar" | "barinfo") + disk_used=${disk_used/G} + disk_used=${disk_used/T} + disk_total=${disk_total/G} + disk_total=${disk_total/T} - case "$disk_info" in - "off") disk="$(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; - *) disk+=" $(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; - esac - fi + case "$disk_info_bar" in + "bar") disk="$(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; + "infobar") disk+=" $(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; + "barinfo") disk="$(bar "${disk_used/'.'}" "${disk_total/'.'}") $disk" ;; + esac + + ;; + esac } # }}} From 2ac5c9e791f7fd7f0a25409507333337ce614682 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sun, 13 Mar 2016 00:00:02 +1100 Subject: [PATCH 3/5] made memory_bar easier to use --- neofetch | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index b342d257..248c805d 100755 --- a/neofetch +++ b/neofetch @@ -1130,12 +1130,11 @@ getmemory () { esac # Progress bars - if [ "$memory_bar" == "on" ]; then - case "$memory_info" in - "off") memory=" $(bar "$memused" "$memtotal")" ;; - *) memory+=" $(bar "$memused" "$memtotal")" ;; - esac - fi + case "$memory_info_bar" in + "bar") memory="$(bar "${memused}" "${memtotal}")" ;; + "infobar") memory="${memory} $(bar "${memused}" "${memtotal}")" ;; + "barinfo") memory="$(bar "${memused}" "${memtotal}") ${memory}" ;; + esac } # }}} From fec784019e326d9f56090853864987827b72513e Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sun, 13 Mar 2016 00:05:48 +1100 Subject: [PATCH 4/5] made battery_bar easier to use --- neofetch | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 248c805d..d9b66561 100755 --- a/neofetch +++ b/neofetch @@ -1540,12 +1540,11 @@ getbattery () { ;; esac - if [ "$battery_bar" == "on" ]; then - case "$battery_info" in - "off") battery="$(bar ${battery/'%'} 100)" ;; - *) battery+=" $(bar ${battery/'%'} 100)" ;; - esac - fi + case "$battery_info_bar" in + "bar") battery="$(bar ${battery/'%'} 100)" ;; + "infobar") battery="${battery} $(bar "${battery/'%'}" 100)" ;; + "barinfo") battery="$(bar "${battery/'%'}" 100) ${battery}" ;; + esac } # }}} From 5080f0fda46a1333f5f030a9e119fa203d34defa Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sun, 13 Mar 2016 07:58:46 +1100 Subject: [PATCH 5/5] fixed issues and added usage info --- neofetch | 98 ++++++++++++++++++++++++++------------------------------ 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/neofetch b/neofetch index d9b66561..4dea730d 100755 --- a/neofetch +++ b/neofetch @@ -115,6 +115,12 @@ shell_version="off" # scaling_current, scaling_min, scaling_max speed_type="max" +# CPU Display +# Set shorthand setting and progress bar setting +# --cpu_display (name, speed, tiny, on, off) (bar, infobar, barinfo, off) +cpu_shorthand="off" +cpu_display="off" + # GPU @@ -257,25 +263,13 @@ progress_color_elapsed="6" progress_color_total="8" # Enable/Disable progress bars -# --cpu_usage_bar on/off -# --memory_bar on/off -# --battery_bar on/off -# --disk_bar on/off -cpu_usage_bar="off" -memory_bar="off" -battery_bar="off" -disk_bar="off" +# --memory_bar bar/infobar/barinfo/off +# --battery_bar bar/infobar/barinfo/off +# --disk_bar bar/infobar/barinfo/off +memory_display="off" +battery_display="off" +disk_display="off" -# Enable/Disable showing just the bar on its own. -# Set this to 'off' to only show the progress bar. -# --cpu_usage_info on/off -# --memory_info on/off -# --battery_info on/off -# --disk_info on/off -cpu_usage_info="on" -memory_info="on" -battery_info="on" -disk_info="on" # }}} @@ -905,22 +899,20 @@ getcpu () { esac # Add CPU info bar - case "$cpu_info_bar" in - "info" | "bar" | "infobar" | "barinfo") - prin "CPU: ${cpu}" - cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')" - cpu_usage="${cpu_usage/\.*}%" + prin "${subtitle}: ${cpu}" - case "$cpu_info_bar" in - "info") prin "CPU Usage: ${cpu_usage}" ;; - "bar") prin "CPU Usage: $(bar "${cpu_usage/'%'}" 100)" ;; - "infobar") prin "CPU Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" 100)" ;; - "barinfo") prin "CPU Usage: $(bar "${cpu_usage/'%'}" 100) ${cpu_usage}" ;; - esac + cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')" + cpu_usage="${cpu_usage/\.*}%" - unset cpu + case "$cpu_display" in + "info") prin "CPU Usage: ${cpu_usage}" ;; + "bar") prin "CPU Usage: $(bar "${cpu_usage/'%'}" 100)" ;; + "infobar") prin "CPU Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" 100)" ;; + "barinfo") prin "CPU Usage: $(bar "${cpu_usage/'%'}" 100) ${cpu_usage}" ;; esac + + unset cpu } # }}} @@ -1130,7 +1122,7 @@ getmemory () { esac # Progress bars - case "$memory_info_bar" in + case "$memory_display" in "bar") memory="$(bar "${memused}" "${memtotal}")" ;; "infobar") memory="${memory} $(bar "${memused}" "${memtotal}")" ;; "barinfo") memory="$(bar "${memused}" "${memtotal}") ${memory}" ;; @@ -1438,20 +1430,15 @@ getdisk () { disk="${disk_used} / ${disk_total} (${disk_total_per})" # Add info bar - case "$disk_info_bar" in - "bar" | "infobar" | "barinfo") - disk_used=${disk_used/G} - disk_used=${disk_used/T} - disk_total=${disk_total/G} - disk_total=${disk_total/T} + disk_used=${disk_used/G} + disk_used=${disk_used/T} + disk_total=${disk_total/G} + disk_total=${disk_total/T} - case "$disk_info_bar" in - "bar") disk="$(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; - "infobar") disk+=" $(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; - "barinfo") disk="$(bar "${disk_used/'.'}" "${disk_total/'.'}") $disk" ;; - esac - - ;; + case "$disk_display" in + "bar") disk="$(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; + "infobar") disk+=" $(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; + "barinfo") disk="$(bar "${disk_used/'.'}" "${disk_total/'.'}") $disk" ;; esac } @@ -1540,7 +1527,7 @@ getbattery () { ;; esac - case "$battery_info_bar" in + case "$battery_display" in "bar") battery="$(bar ${battery/'%'} 100)" ;; "infobar") battery="${battery} $(bar "${battery/'%'}" 100)" ;; "barinfo") battery="$(bar "${battery/'%'}" 100) ${battery}" ;; @@ -2438,10 +2425,15 @@ usage () { cat << EOF --progress_length num Length in spaces to make the progress bars. --progress_colors num num Colors to make the progress bar. Set in this order: elapsed, total - --cpu_usage_bar on/off Whether or not to print a progress bar for cpu usage. - --memory_bar on/off Whether or not to print a progress bar for memory usage. - --battery_bar on/off Whether or not to print a progress bar for battery usage. - --disk_bar on/off Whether or not to print a progress bar for disk usage. + --cpu_display mode1 mode2 Which shorthand to use and how CPU usage should be printed + mode1 takes: name, speed, tiny, on, off + mode2 takes: info, bar, infobar, barinfo + --memory_display mode Which way should the memory progress bar be added + Takes bar, infobar, barinfo + --battery_display mode Which way should the battery progress bar be added + Takes bar, infobar, barinfo + --disk_display mode Which way should the disk progress bar be added + Takes bar, infobar, barinfo Image: @@ -2566,11 +2558,11 @@ while [ "$1" ]; do ;; --cpu_display) cpu_shorthand="$2" - cpu_info_bar="$3" + cpu_display="$3" ;; - --memory_info_bar) memory_info_bar="$2" ;; - --battery_info_bar) battery_info_bar="$2" ;; - --disk_info_bar) disk_info_bar="$2" ;; + --memory_display) memory_display="$2" ;; + --battery_display) battery_display="$2" ;; + --disk_display) disk_display="$2" ;; # Image --image)