Skip to content

Commit 5b0f4b5

Browse files
Merge pull request #297 from NeumoNeumo/patch-1
Fix: get status and capacity with multiple power_supplies
2 parents 66e0910 + 25ef966 commit 5b0f4b5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

scripts/battery.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ linux_acpi() {
99
arg=$1
1010
BAT=$(ls -d /sys/class/power_supply/*)
1111
if [ ! -x "$(which acpi 2> /dev/null)" ];then
12-
case "$arg" in
13-
status)
14-
cat $BAT/status
15-
;;
16-
17-
percent)
18-
cat $BAT/capacity
19-
;;
20-
21-
*)
22-
;;
23-
esac
12+
for DEV in $BAT; do
13+
case "$arg" in
14+
status)
15+
[ -f "$DEV/status" ] && cat "$DEV/status"
16+
;;
17+
percent)
18+
[ -f "$DEV/capacity" ] && cat "$DEV/capacity"
19+
;;
20+
*)
21+
;;
22+
esac
23+
done
2424
else
2525
case "$arg" in
2626
status)

0 commit comments

Comments
 (0)