diff --git a/bin/omarchy-battery-status b/bin/omarchy-battery-status index 7f642e620137..49d194af239d 100755 --- a/bin/omarchy-battery-status +++ b/bin/omarchy-battery-status @@ -172,7 +172,10 @@ battery_full=false if [[ $state == "fully-charged" ]]; then battery_full=true elif [[ $ac_online == "true" ]] && (( percentage >= 100 )); then - battery_full=true + # A load bigger than the adapter drains a battery that still reads 100%. + if [[ $state != "discharging" || $charge_idle == "true" ]]; then + battery_full=true + fi fi parts=("$(omarchy-i18n battery.statusLabel "$percentage")") diff --git a/test/shell.d/battery-status-test.sh b/test/shell.d/battery-status-test.sh index a86f5cea45b1..07441943fa53 100644 --- a/test/shell.d/battery-status-test.sh +++ b/test/shell.d/battery-status-test.sh @@ -188,6 +188,13 @@ printf '0\n' >"$hold_dir/power/BAT0/power_now" full_output=$(OMARCHY_POWER_SUPPLY_PATH="$hold_dir/power" PATH="$hold_dir/bin:$PATH" "$ROOT/bin/omarchy-battery-status") [[ $full_output == "Battery 100% · Fully charged · 53Wh" ]] || fail "a full battery shows no time or draw" "$full_output" +# A load bigger than the adapter drains a battery still reading 100%. +sed -i 's/state: fully-charged/state: discharging/' "$hold_dir/bin/upower" +printf '10000000\n' >"$hold_dir/power/BAT0/power_now" +draining_output=$(OMARCHY_POWER_SUPPLY_PATH="$hold_dir/power" PATH="$hold_dir/bin:$PATH" "$ROOT/bin/omarchy-battery-status") +[[ $draining_output == "Battery 100% · 5h 19m left · "*"10W"*"53Wh" ]] || fail "a battery draining on AC at 100% is not fully charged" "$draining_output" +sed -i 's/state: discharging/state: fully-charged/' "$hold_dir/bin/upower" + # A battery with no time estimate and no capacity reading leaves both out. sed -i 's/state: fully-charged/state: discharging/; s/percentage: 100%/percentage: 60%/; /energy/d' "$hold_dir/bin/upower" printf '0\n' >"$hold_dir/power/ac/online"