mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-20 13:33:23 -07:00
* usr/lib/byobu/battery: LP: #851100
- rework the battery logic to use /sys instead of /proc
This commit is contained in:
parent
3b99c3c215
commit
e02be1f46a
2 changed files with 55 additions and 40 deletions
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -19,6 +19,8 @@ byobu (4.43) unreleased; urgency=low
|
||||||
* usr/lib/byobu/.dirs:
|
* usr/lib/byobu/.dirs:
|
||||||
- use /dev/shm for cache, LP: #872551, #869279
|
- use /dev/shm for cache, LP: #872551, #869279
|
||||||
- search and use a shared dir when possible
|
- search and use a shared dir when possible
|
||||||
|
* usr/lib/byobu/battery: LP: #851100
|
||||||
|
- rework the battery logic to use /sys instead of /proc
|
||||||
|
|
||||||
[ Daniel Hahler ]
|
[ Daniel Hahler ]
|
||||||
* usr/bin/byobu, usr/bin/byobu-launcher-install, usr/bin/byobu-
|
* usr/bin/byobu, usr/bin/byobu-launcher-install, usr/bin/byobu-
|
||||||
|
|
|
@ -30,9 +30,21 @@ __battery_detail() {
|
||||||
|
|
||||||
__battery() {
|
__battery() {
|
||||||
local bat line present sign state percent full rem color bcolor
|
local bat line present sign state percent full rem color bcolor
|
||||||
for bat in $BATTERY /proc/acpi/battery/*; do
|
for bat in $BATTERY /sys/class/power_supply/* /proc/acpi/battery/*; do
|
||||||
[ -f "$bat/info" ] || continue
|
|
||||||
present=""; full=""; rem=""; state=""
|
present=""; full=""; rem=""; state=""
|
||||||
|
case "$bat" in
|
||||||
|
/sys/*)
|
||||||
|
if [ -r "$bat/uevent" ]; then
|
||||||
|
. "$bat/uevent"
|
||||||
|
present="$POWER_SUPPLY_PRESENT"
|
||||||
|
full="$POWER_SUPPLY_CHARGE_FULL"
|
||||||
|
rem="$POWER_SUPPLY_CHARGE_NOW"
|
||||||
|
state="$POWER_SUPPLY_STATUS"
|
||||||
|
[ -n "$present" ] && [ -n "$full" ] && [ -n "$rem" ] && [ "$state" ] && break
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
/proc/*)
|
||||||
|
[ -f "$bat/info" ] || continue
|
||||||
while read line; do
|
while read line; do
|
||||||
set -- ${line}
|
set -- ${line}
|
||||||
case "$line" in
|
case "$line" in
|
||||||
|
@ -52,6 +64,9 @@ __battery() {
|
||||||
esac
|
esac
|
||||||
[ -n "$rem" -a -n "$state" ] && break
|
[ -n "$rem" -a -n "$state" ] && break
|
||||||
done < "$bat/state"
|
done < "$bat/state"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
percent=$(((100*$rem)/$full))
|
percent=$(((100*$rem)/$full))
|
||||||
if [ "$percent" -lt 33 ]; then
|
if [ "$percent" -lt 33 ]; then
|
||||||
color="R k"
|
color="R k"
|
||||||
|
@ -65,14 +80,12 @@ __battery() {
|
||||||
fi
|
fi
|
||||||
percent="$percent$PCT"
|
percent="$percent$PCT"
|
||||||
case $state in
|
case $state in
|
||||||
charging) sign="+" ;;
|
charging|Charging|Unknown) sign="+" ;;
|
||||||
discharging) sign="-" ;;
|
discharging|Discharging) sign="-" ;;
|
||||||
charged) sign="="; percent="" ;;
|
charged|Unknown) sign="="; percent="" ;;
|
||||||
*) sign="$state" ;;
|
*) sign="$state" ;;
|
||||||
esac
|
esac
|
||||||
color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color --
|
color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color --
|
||||||
break
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# vi: syntax=sh ts=4 noexpandtab
|
# vi: syntax=sh ts=4 noexpandtab
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue