From 33e9a0668ea27b6199a31fca4c2bcc00e43d6d87 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Thu, 1 Dec 2022 16:36:06 -0500 Subject: [PATCH] Added status to the output in the batteryzu script. fixed the shabang. Fixed formatting. --- scripts/battery_status.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/battery_status.sh b/scripts/battery_status.sh index 8ad47a1..26f30d6 100755 --- a/scripts/battery_status.sh +++ b/scripts/battery_status.sh @@ -1,17 +1,18 @@ +#!/usr/bin/env bash #check for acpi if command -v acpi &> /dev/null; then - bat=$(acpi -b) + bat="$(acpi -b)" spd-say -P important -Cw "$bat" else find /sys/class/power_supply -type l -exec bash -c ' - for i ; do - if [[ -e "$i/capacity" ]]; then - bat="${i##*/}" - bat="${bat//BAT/Battery }" - bat="${bat}: $(cat "${i}/capacity") percent" - spd-say -P important -Cw "$bat" - fi - done -' _ {} \; -fi + for i ; do + if [[ -e "$i/capacity" ]]; then + bat="${i##*/}" + bat="${bat//BAT/Battery }" + bat="${bat}: $( { cat "${i}/status";echo -n ", "; cat "${i}/capacity"; } | tr -d \\n) percent." + spd-say -P important -Cw "$bat" + fi + done + ' _ {} \; +fi