Don't show battery if there is no voltage since detection not working properly - on legacy kernel and a fix for IP detection

This commit is contained in:
Igor Pecovnik 2016-01-30 19:33:28 +01:00
parent 4d962842cd
commit f0b238dd9a

View file

@ -73,8 +73,10 @@ fi
# legacy kernel
axp_dir="/sys/class/power_supply"
if [[ -e "$axp_dir" && -e "$axp_dir/battery" ]]; then
status_battery_text=" "$(cat $axp_dir/battery/status | awk '{print tolower($0)}')
battery_percent=$(cat $axp_dir/battery/capacity)
if [[ (("$(cat $axp_dir/battery/voltage_now)" -gt "0" )) ]]; then
status_battery_text=" "$(cat $axp_dir/battery/status | awk '{print tolower($0)}')
battery_percent=$(cat $axp_dir/battery/capacity)
fi
fi
@ -87,7 +89,7 @@ users=$(users | wc -w)
swap_total=$(free -m | awk '/Swap/ { printf("%3.0f", $3/$2*100) }' | sed 's/ //g')
swap_usage=${swap_usage//[!0-9]/} # to remove alfanumeric if swap not used
swap_total=$(free -m | awk '/Swap/ {print $(2)}')
ip_address=$((ifconfig br0 || ifconfig eth0 || ifconfig wlan0) | sed -n '/inet addr/s/.*addr.\([^ ]*\) .*/\1/p')
ip_address=$((ifconfig -a) | sed -n '/inet addr/s/.*addr.\([^ ]*\) .*/\1/p' | head -1)
root_usage=$(df -h / | awk '/\// {print $(NF-1)}' | sed 's/%//g')
root_total=$(df -h / | awk '/\// {print $(NF-4)}')
if [ -e "$storage" ]; then