Skip to content

Commit

Permalink
Merge pull request yaocccc#24 from BingCoke/master
Browse files Browse the repository at this point in the history
修改一下upower更新逻辑
  • Loading branch information
yaocccc authored Mar 3, 2023
2 parents 6c9565c + 0cc5c91 commit e15ae84
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions DEF/statusbar/packages/bat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ get_by_acpi() {
[ ! "$(command -v acpi)" ] && echo command not found: acpi && return
bat_text=$(acpi -b | sed '2,$d' | awk '{print $4}' | grep -Eo "[0-9]+")
[ ! "$bat_text" ] && bat_text=$(acpi -b | sed '2,$d' | awk -F'[ %]' '{print $5}' | grep -Eo "[0-9]+")
[ ! "$(acpi -b | grep 'Battery 0' | grep Discharging)" ] && charge_icon=""
[ ! "$(acpi -b | grep 'Battery 0' | grep Discharging)" ] &&
[ -n "$(acpi -a | grep on-line)" ] && charge_icon=""
_time="可用时间: $(acpi | sed 's/^Battery 0: //g' | awk -F ',' '{print $3}' | sed 's/^[ ]//g' | awk '{print $1}')"
[ "$_time" = "可用时间: " ] && _time=""
}

get_by_upower() {
[ -n "$bat_text" ] && [ $bat_text -gt 0 ] && return
[ ! "$(command -v upower)" ] && echo command not found: upower && return
bat=$(upower -e | grep BAT)
bat_text=$(upower -i $bat | awk '/percentage/ {print $2}' | grep -Eo '[0-9]+')
charge_icon=""
[ -z "$(upower -i $bat | grep 'state:.*fully-charged')" ] && charge_icon=""
[ -n "$(upower -i $bat | grep 'state:.*fully-charged')" ] && charge_icon=""
}

update() {
Expand Down

0 comments on commit e15ae84

Please sign in to comment.