|
|
|
|
@ -135,6 +135,14 @@ gtk2="on" |
|
|
|
|
gtk3="on" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Battery |
|
|
|
|
|
|
|
|
|
# Which battery to display. |
|
|
|
|
# By default we display all batteries. |
|
|
|
|
# --battery_num all, 0, 1, 2, etc |
|
|
|
|
battery_num="all" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Birthday |
|
|
|
|
|
|
|
|
|
# Whether to show a long pretty output |
|
|
|
|
@ -1189,26 +1197,32 @@ getbattery () { |
|
|
|
|
case "$os" in |
|
|
|
|
"Linux") |
|
|
|
|
if [ -d "/sys/class/power_supply/BAT0" ]; then |
|
|
|
|
batteries=($(cat /sys/class/power_supply/BAT*/capacity)) |
|
|
|
|
# Set the index to the battery number. |
|
|
|
|
case "$battery_num" in |
|
|
|
|
"all") battery_num="*" index=0 ;; |
|
|
|
|
*) index="$battery_num" ;; |
|
|
|
|
esac |
|
|
|
|
|
|
|
|
|
# Create an array of battery usage from each battery. |
|
|
|
|
batteries=($(cat /sys/class/power_supply/BAT${battery_num}/capacity)) |
|
|
|
|
|
|
|
|
|
# Get the subtitle and reassign it so it doesn't change. |
|
|
|
|
title="$subtitle" |
|
|
|
|
|
|
|
|
|
# If there's only a single battery, |
|
|
|
|
# don't number the subtitle. |
|
|
|
|
if [ "${#batteries[@]}" == 1 ]; then |
|
|
|
|
if [ "${#batteries[@]}" == 1 ] && [ "$battery_num" == 0 ]; then |
|
|
|
|
prin "${title}: ${batteries[0]}%" |
|
|
|
|
return |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# Print each battery on a seperate line. |
|
|
|
|
index=0 |
|
|
|
|
for bat in ${batteries[@]}; do |
|
|
|
|
prin "${title}${index}: ${bat}%" |
|
|
|
|
index=$((index + 1)) |
|
|
|
|
done |
|
|
|
|
else |
|
|
|
|
battery="Unknown" |
|
|
|
|
battery="None" |
|
|
|
|
fi |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|
|