From ee892cf2154aa0a56d8a1e15f1d581fdac2b7f73 Mon Sep 17 00:00:00 2001 From: van Date: Mon, 23 Mar 2020 15:50:46 +0800 Subject: [PATCH] Fix MacOSX Catalina without battery situation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Situation ```zsh ✗ pmset -g batt Now drawing from 'AC Power' ``` When I use `pmset` command using in helpers.sh, I get above output.My PC does not have battery, so the plugin cannot display it well. So I add some judgment for supporting the PC without battery. Signed-off-by: van --- scripts/helpers.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/helpers.sh b/scripts/helpers.sh index 067c120..3048ac3 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -29,7 +29,12 @@ command_exists() { battery_status() { if command_exists "pmset"; then - pmset -g batt | awk -F '; *' 'NR==2 { print $2 }' + RES=`pmset -g batt | awk -F '; *' 'NR==2 { print $2 }'` + if [ "$RES" = "" ];then + echo "Now drawing from 'AC Power'\n-InternalBattery-0 100%; charged; 0:00 remaining" + else + echo "$RES" + fi elif command_exists "acpi"; then acpi -b | awk '{gsub(/,/, ""); print tolower($3); exit}' elif command_exists "upower"; then