mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -07:00
whitespace only changes
use tabs rather than 4 spaces Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
This commit is contained in:
parent
82267654f8
commit
8c48454a70
1 changed files with 39 additions and 40 deletions
79
bin/battery
79
bin/battery
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
|
|
||||||
search () {
|
search () {
|
||||||
local str expr
|
local str expr
|
||||||
str="$1"
|
str="$1"
|
||||||
expr="$2"
|
expr="$2"
|
||||||
echo "$str" | sed -n "s/${expr}/\1/p"
|
echo "$str" | sed -n "s/${expr}/\1/p"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,43 +36,42 @@ if [ "$1" = "--detail" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for bat in $(ls /proc/acpi/battery); do
|
for bat in $(ls /proc/acpi/battery); do
|
||||||
# make sure that this battery is present
|
# make sure that this battery is present
|
||||||
infofile=$(cat "/proc/acpi/battery/$bat/info")
|
infofile=$(cat "/proc/acpi/battery/$bat/info")
|
||||||
present=$(search "$infofile" "present: *\(.*\)")
|
present=$(search "$infofile" "present: *\(.*\)")
|
||||||
[ "${present}" = "no" ] && continue
|
[ "${present}" = "no" ] && continue
|
||||||
|
|
||||||
# obtain full and remaining battery values
|
# obtain full and remaining battery values
|
||||||
statefile=$(cat "/proc/acpi/battery/$bat/state")
|
statefile=$(cat "/proc/acpi/battery/$bat/state")
|
||||||
full=$(search "$infofile" "last full capacity: *\(.*\) m[AW]h")
|
full=$(search "$infofile" "last full capacity: *\(.*\) m[AW]h")
|
||||||
rem=$(search "$statefile" "remaining capacity: *\(.*\) m[AW]h")
|
rem=$(search "$statefile" "remaining capacity: *\(.*\) m[AW]h")
|
||||||
|
|
||||||
percent=$( echo "$rem" "$full" | awk '{printf "%.0f", 100*$1/$2}')
|
percent=$( echo "$rem" "$full" | awk '{printf "%.0f", 100*$1/$2}')
|
||||||
if [ "$percent" -lt 33 ]; then
|
if [ "$percent" -lt 33 ]; then
|
||||||
per_color="{= Rk}"
|
per_color="{= Rk}"
|
||||||
elif [ "$percent" -lt 67 ]; then
|
elif [ "$percent" -lt 67 ]; then
|
||||||
per_color="{= Yk}"
|
per_color="{= Yk}"
|
||||||
else
|
else
|
||||||
per_color="{= Gk}"
|
per_color="{= Gk}"
|
||||||
fi
|
fi
|
||||||
percent="$percent%"
|
percent="$percent%"
|
||||||
|
|
||||||
|
state=$(search "$statefile" "charging state: *\(.*\)")
|
||||||
state=$(search "$statefile" "charging state: *\(.*\)")
|
case $state in
|
||||||
case $state in
|
charging)
|
||||||
charging)
|
sign="+"
|
||||||
sign="+"
|
;;
|
||||||
;;
|
discharging)
|
||||||
discharging)
|
sign="-"
|
||||||
sign="-"
|
;;
|
||||||
;;
|
charged)
|
||||||
charged)
|
sign="="
|
||||||
sign="="
|
percent=
|
||||||
percent=
|
;;
|
||||||
;;
|
*)
|
||||||
*)
|
sign="$state"
|
||||||
sign="$state"
|
;;
|
||||||
;;
|
esac
|
||||||
esac
|
printf "\005%s%s|%s|\005{-} " "$per_color" "$percent" "$sign"
|
||||||
printf "\005%s%s|%s|\005{-} " "$per_color" "$percent" "$sign"
|
break
|
||||||
break
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue