From 41cb522d2ce21cc71048e917ebf02514e24611c6 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Fri, 2 Jun 2023 19:31:14 +0100 Subject: [PATCH] Switch between battery charging/not icons --- system-info/system-info-Linux.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/system-info/system-info-Linux.sh b/system-info/system-info-Linux.sh index ed9f468..62e22fc 100755 --- a/system-info/system-info-Linux.sh +++ b/system-info/system-info-Linux.sh @@ -24,11 +24,18 @@ fi if [ "`acpi -b`" != "No support for device type: power_supply" ]; then function get_battery { - acpi -b | \ - awk '{ print $4 }' | \ - awk '$battery ~ /.*/ { - printf "%3d%% %s\n", $battery, substr("󰂎󰁺󰁻󰁼󰁽󰁾󰁿󰂀󰂁󰂂󰁹", int($battery / 9), 1) - }' + local output=$(acpi -b) + local charging=$(echo $output | awk '{ print $3 }') + local percentage=$(echo $output | awk '{ print $4 }') + if [ "$charging" = "Charging," ];then + echo $percentage | awk '$battery ~ /.*/ { + printf "%3d%% %s\n", $battery, substr("󰢟󰢜󰂆󰂇󰂈󰢝󰂉󰢞󰂊󰂋󰂅", int($battery / 9), 1) + }' + else + echo $percentage | awk '$battery ~ /.*/ { + printf "%3d%% %s\n", $battery, substr("󰂎󰁺󰁻󰁼󰁽󰁾󰁿󰂀󰂁󰂂󰁹", int($battery / 9), 1) + }' + fi } else function get_battery {