From 85a0e2cc809dfc455280042ce6ab64a86d295f0b Mon Sep 17 00:00:00 2001 From: dawidd6 Date: Sun, 20 Mar 2016 13:02:36 +0100 Subject: [PATCH 1/2] added power status for single battery --- neofetch | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index cfaea51b..a285e581 100755 --- a/neofetch +++ b/neofetch @@ -1551,7 +1551,8 @@ getbattery () { # Create an array of battery usage from each battery. batteries=($(cat /sys/class/power_supply/BAT${battery_num}/capacity)) - + # Get the power status + power_status=($(cat /sys/class/power_supply/BAT${battery_num}/status)) # Get the subtitle and reassign it so it doesn't change. title="$subtitle" @@ -1572,14 +1573,14 @@ getbattery () { "bar") prin "${title}${index}: $(bar ${bat/'%'} 100)" ;; "infobar") prin "${title}${index}: ${bat}% $(bar "${bat/'%'}" 100)" ;; "barinfo") prin "${title}${index}: $(bar "${bat/'%'}" 100) ${bat}%" ;; - *) prin "${title}${index}: ${bat}%" ;; + *) prin "${title}${index}: ${bat}% " ;; esac index=$((index + 1)) done return fi - battery="${batteries[0]}%" + battery="${batteries[0]}% ${power_status}" fi else battery="None" From 5bcaa342a8ef4639f95fecf2ee53577928f32e47 Mon Sep 17 00:00:00 2001 From: dawidd6 Date: Sun, 20 Mar 2016 15:06:28 +0100 Subject: [PATCH 2/2] fixed battery_status to show only charging status + added battery_status to FreeBSD --- neofetch | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index a285e581..e4542966 100755 --- a/neofetch +++ b/neofetch @@ -1573,14 +1573,17 @@ getbattery () { "bar") prin "${title}${index}: $(bar ${bat/'%'} 100)" ;; "infobar") prin "${title}${index}: ${bat}% $(bar "${bat/'%'}" 100)" ;; "barinfo") prin "${title}${index}: $(bar "${bat/'%'}" 100) ${bat}%" ;; - *) prin "${title}${index}: ${bat}% " ;; + *) prin "${title}${index}: ${bat}%" ;; esac index=$((index + 1)) done return fi - - battery="${batteries[0]}% ${power_status}" + if [ $power_status = "Charging" ]; then + battery="${batteries[0]}% ${power_status}" + else + battery="${batteries[0]}%" + fi fi else battery="None" @@ -1590,7 +1593,13 @@ getbattery () { "BSD") case "$distro" in "FreeBSD"*) + power_status=$(acpiconf -i 0 | awk -F ':\t\t\t' '/State/ {print $2}') + + if [ $power_status = "charging" ]; then + battery="$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}') $power_status" + else battery=$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}') + fi ;; "NetBSD"*)