From f87f2e4268d13e24b2101aa9233fcfc6f27e3dec Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Wed, 30 Nov 2022 17:47:37 -0500 Subject: [PATCH] Updated the battery status script. --- scripts/battery_status.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/battery_status.sh b/scripts/battery_status.sh index 8204e01..6388ea5 100755 --- a/scripts/battery_status.sh +++ b/scripts/battery_status.sh @@ -1,10 +1,13 @@ -#!/bin/env bash -#Get battery status -cd /sys/class/power_supply -for f in `ls`; do -if [ -e $f"/capacity" ]; then -export stat=`cat $f"/status"` -export cap=`cat $f"/capacity"` -echo battery $f": "$stat", "$cap"%" -fi -done|spd-say -e \ No newline at end of file +#!/usr/bin/env bash + +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 +' _ {} \; +