From 7a661b396649eefb92781640557595f6e0e57e39 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 20 Oct 2016 17:32:29 +1100 Subject: [PATCH] Fix bugs --- neofetch | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/neofetch b/neofetch index bdbc12cf..cd3e9a8a 100755 --- a/neofetch +++ b/neofetch @@ -465,8 +465,6 @@ getpackages() { packages="$(pkg list | wc -l)" ;; esac - - [ "$packages" == 0 ] && unset packages } # }}} @@ -1736,8 +1734,17 @@ getbattery() { *) index="$battery_num" ;; esac - batteries=($(cat /sys/class/power_supply/battery/capacity /sys/class/power_supply/BAT${battery_num}/capacity)) - battery_state=($(cat /sys/class/power_supply/battery/status /sys/class/power_supply/BAT${battery_num}/status)) + case "$distro" in + "Android"*) + batteries="$(< /sys/class/power_supply/battery/capacity)" + battery_state="$(< /sys/class/power_supply/battery/status)" + ;; + + *) + batteries=($(< /sys/class/power_supply/BAT${battery_num}/capacity)) + battery_state=($(< /sys/class/power_supply/BAT${battery_num}/status)) + ;; + esac # Get the subtitle and reassign it so it doesn't change. title="$subtitle" @@ -2082,10 +2089,12 @@ getascii() { ascii_strip="${ascii_strip//'\\'/ }" ascii_strip="${ascii_strip//'\'}" - # Get length of the ascii file. + # Get lines/columns of the ascii file. ascii_length=0 - while IFS='' read -r line 2>/dev/null; do + lines=1 + while IFS='\n' read -r line 2>/dev/null; do [ "${#line}" -gt "$ascii_length" ] && ascii_length="${#line}" + lines="$((lines+=1))" done <<< "$ascii_strip" # Workaround for calculating length of block chars @@ -2093,7 +2102,6 @@ getascii() { block_char="█" [ "${#block_char}" == 3 ] && ascii_length="$((ascii_length / 3 + 2))" - lines="$(printf "%s\n" "$ascii_strip" | wc -l)" padding="\033[$((ascii_length + gap))C" printf "%b%s" "$print" export LC_ALL=C