mirror of
https://github.com/actuallymentor/battery.git
synced 2026-02-03 05:53:24 +00:00
Check if AC is connected when charge is above threshold
This commit is contained in:
@@ -204,6 +204,11 @@ function get_remaining_time() {
|
||||
echo "$time_remaining"
|
||||
}
|
||||
|
||||
function get_charger_state() {
|
||||
ac_attached=$(pmset -g batt | tail -n1 | awk '{ x=match($0, /AC attached/) > 0; print x }')
|
||||
echo "$ac_attached"
|
||||
}
|
||||
|
||||
function get_maintain_percentage() {
|
||||
maintain_percentage=$(cat $maintain_percentage_tracker_file 2>/dev/null)
|
||||
echo "$maintain_percentage"
|
||||
@@ -443,8 +448,9 @@ if [[ "$action" == "maintain_synchronous" ]]; then
|
||||
|
||||
# Keep track of status
|
||||
is_charging=$(get_smc_charging_status)
|
||||
ac_attached=$(get_charger_state)
|
||||
|
||||
if [[ "$battery_percentage" -ge "$setting" && "$is_charging" == "enabled" ]]; then
|
||||
if [[ "$battery_percentage" -ge "$setting" && ( "$is_charging" == "enabled" || "$ac_attached" == "1" ) ]]; then
|
||||
|
||||
log "Charge above $setting"
|
||||
disable_charging
|
||||
|
||||
Reference in New Issue
Block a user