From d2fb41585619a32e4741e612ddf1a5ee348c4cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20S=C3=A1nchez?= Date: Mon, 3 Jul 2017 12:09:27 -0500 Subject: [PATCH 1/2] Update atomic.theme.bash Improvements in the theme --- themes/atomic/atomic.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/atomic/atomic.theme.bash b/themes/atomic/atomic.theme.bash index 3df4e7ce..6dd7ea04 100644 --- a/themes/atomic/atomic.theme.bash +++ b/themes/atomic/atomic.theme.bash @@ -177,8 +177,8 @@ ___atomic_prompt_battery() { color=$IRed fi box="[|]" - ac_adapter_disconnected && info="-" ac_adapter_connected && info="+" + ac_adapter_disconnected && info="-" info+=$batp [ "$batp" -eq 100 ] || [ "$batp" -gt 100 ] && info="AC" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" From a3e714e175d7d4d8dc539beb03da1b725b98237f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20S=C3=A1nchez?= Date: Wed, 12 Jul 2017 18:59:47 -0500 Subject: [PATCH 2/2] Update battery.plugin.bash Added **pmset** command that improves the process of detecting the battery and its percentage --- plugins/available/battery.plugin.bash | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash index 864d914b..dd941372 100644 --- a/plugins/available/battery.plugin.bash +++ b/plugins/available/battery.plugin.bash @@ -10,6 +10,10 @@ ac_adapter_connected(){ then acpi -a | grep -q "on-line" return $? + elif command_exists pmset; + then + pmset -g batt | grep -q 'AC Power' + return $? elif command_exists ioreg; then ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes' @@ -30,6 +34,10 @@ ac_adapter_disconnected(){ then acpi -a | grep -q "off-line" return $? + elif command_exists pmset; + then + pmset -g batt | grep -q 'Battery Power' + return $? elif command_exists ioreg; then ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No' @@ -76,6 +84,17 @@ battery_percentage(){ echo '-1' ;; esac + elif command_exists pmset; + then + local PMSET_OUTPUT=$(pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p') + case $PMSET_OUTPUT in + 100*) + echo '100' + ;; + *) + echo $PMSET_OUTPUT | head -c 2 + ;; + esac elif command_exists ioreg; then local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}')