From 2ae20041ba45d1dd611dd4945093ea0d4d4538a4 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Mon, 14 Mar 2016 21:21:43 +1100 Subject: [PATCH 1/6] fixed output of disk bar when gigabytes are used of a terbyte disk --- neofetch | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 3ad1c8c1..3f532ce2 100755 --- a/neofetch +++ b/neofetch @@ -1505,9 +1505,21 @@ getdisk () { # Add info bar disk_used=${disk_used/G} - disk_used=${disk_used/T} disk_total=${disk_total/G} - disk_total=${disk_total/T} + + if [[ "$disk_used" == *"T" ]]; then + touch "terabyte_used" + disk_used=${disk_used/T} + disk_used=$(echo "${disk_used} * 1000" | bc) + disk_used=${disk_used/'.'*} + fi + + if [[ "$disk_total" == *"T" ]]; then + touch "terabyte_total" + disk_total=${disk_total/T} + disk_total=$(echo "${disk_total} * 1000" | bc) + disk_total=${disk_total/'.'*} + fi case "$disk_display" in "bar") disk="$(bar "${disk_used/'.'}" "${disk_total/'.'}")" ;; From 3cb804f95b4ca56bcf60416de2151845059d9698 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Mon, 14 Mar 2016 21:26:04 +1100 Subject: [PATCH 2/6] oops there was a debug line... --- neofetch | 2 -- 1 file changed, 2 deletions(-) diff --git a/neofetch b/neofetch index 3f532ce2..2eba2312 100755 --- a/neofetch +++ b/neofetch @@ -1508,14 +1508,12 @@ getdisk () { disk_total=${disk_total/G} if [[ "$disk_used" == *"T" ]]; then - touch "terabyte_used" disk_used=${disk_used/T} disk_used=$(echo "${disk_used} * 1000" | bc) disk_used=${disk_used/'.'*} fi if [[ "$disk_total" == *"T" ]]; then - touch "terabyte_total" disk_total=${disk_total/T} disk_total=$(echo "${disk_total} * 1000" | bc) disk_total=${disk_total/'.'*} From 34f145b7b175dca38aca15e4ddc3dd64370a559b Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Mon, 14 Mar 2016 21:29:48 +1100 Subject: [PATCH 3/6] made the if statements shorter --- neofetch | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 2eba2312..bd5e4b78 100755 --- a/neofetch +++ b/neofetch @@ -1508,14 +1508,12 @@ getdisk () { disk_total=${disk_total/G} if [[ "$disk_used" == *"T" ]]; then - disk_used=${disk_used/T} - disk_used=$(echo "${disk_used} * 1000" | bc) + disk_used=$(echo "${disk_used/T} * 1000" | bc) disk_used=${disk_used/'.'*} fi if [[ "$disk_total" == *"T" ]]; then - disk_total=${disk_total/T} - disk_total=$(echo "${disk_total} * 1000" | bc) + disk_total=$(echo "${disk_total/T} * 1000" | bc) disk_total=${disk_total/'.'*} fi From c0a6886dcc1947f7dbe67540e77df00b5c671c9c Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Mon, 14 Mar 2016 21:33:14 +1100 Subject: [PATCH 4/6] changed from echo to printf --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index bd5e4b78..ce1e2dcb 100755 --- a/neofetch +++ b/neofetch @@ -1508,12 +1508,12 @@ getdisk () { disk_total=${disk_total/G} if [[ "$disk_used" == *"T" ]]; then - disk_used=$(echo "${disk_used/T} * 1000" | bc) + disk_used=$(printf "%s\n" "${disk_used/T} * 1000" | bc) disk_used=${disk_used/'.'*} fi if [[ "$disk_total" == *"T" ]]; then - disk_total=$(echo "${disk_total/T} * 1000" | bc) + disk_total=$(printf "%s\n" "${disk_total/T} * 1000" | bc) disk_total=${disk_total/'.'*} fi From 712500a17091481a0d8bb295aff88a8d37febbce Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Mon, 14 Mar 2016 21:39:02 +1100 Subject: [PATCH 5/6] moved removal of '.'* to the actual printing of infobar --- neofetch | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index ce1e2dcb..460746de 100755 --- a/neofetch +++ b/neofetch @@ -1509,18 +1509,16 @@ getdisk () { if [[ "$disk_used" == *"T" ]]; then disk_used=$(printf "%s\n" "${disk_used/T} * 1000" | bc) - disk_used=${disk_used/'.'*} fi if [[ "$disk_total" == *"T" ]]; then disk_total=$(printf "%s\n" "${disk_total/T} * 1000" | bc) - disk_total=${disk_total/'.'*} fi 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" ;; + "bar") disk="$(bar "${disk_used/'.'*}" "${disk_total/'.'*}")" ;; + "infobar") disk+=" $(bar "${disk_used/'.'*}" "${disk_total/'.'*}")" ;; + "barinfo") disk="$(bar "${disk_used/'.'*}" "${disk_total/'.'*}") $disk" ;; esac } From a7806d6c090c7873ef5768ba08f6b9208fe0d0fb Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Mon, 14 Mar 2016 21:41:14 +1100 Subject: [PATCH 6/6] changed to 1 line if statements --- neofetch | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 460746de..19c19166 100755 --- a/neofetch +++ b/neofetch @@ -1507,13 +1507,11 @@ getdisk () { disk_used=${disk_used/G} disk_total=${disk_total/G} - if [[ "$disk_used" == *"T" ]]; then + [[ "$disk_used" == *"T" ]] && \ disk_used=$(printf "%s\n" "${disk_used/T} * 1000" | bc) - fi - if [[ "$disk_total" == *"T" ]]; then + [[ "$disk_total" == *"T" ]] && \ disk_total=$(printf "%s\n" "${disk_total/T} * 1000" | bc) - fi case "$disk_display" in "bar") disk="$(bar "${disk_used/'.'*}" "${disk_total/'.'*}")" ;;