Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/omarchy-battery-status
Original file line number Diff line number Diff line change
Expand Up @@ -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")")
Expand Down
7 changes: 7 additions & 0 deletions test/shell.d/battery-status-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading