Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling charging limit puts the laptop to sleep when in clamshell mode. #89

Closed
cholcombe973 opened this issue Feb 24, 2023 · 4 comments

Comments

@cholcombe973
Copy link

cholcombe973 commented Feb 24, 2023

What is the issue? (required)
I'm not entirely sure what is going on but it seems like when I enable the 80% charging limit while the laptop is in clamshell mode with a monitor and power plugged it goes to sleep. I get a notification in the side tray about background items have been enabled and then the laptop goes right to sleep. If I open the laptop up and log back in it goes right back to sleep. I'm currently on version 1.0.9
I'm wondering if the battery daemon is conflicting with the battery optimizer that comes with MacOs.

What exactly did you do to produce the issue? (required)
Steps to reproduce the behavior:

  1. Install battery
  2. Enable the 80% limit while in clamshell mode
  3. Computer goes to sleep
  4. Wake computer up and log in again
  5. Disable 80% limit
  6. Go back into clamshell mode
  7. Enable 80% limit and computer goes back to sleep
  8. See error logs

Expected behavior (required)
The behavior I'm looking for is allowing the charging limit to stay in place while in clamshell mode.

Error logs
battery_logs.gz

Did battery fail to install? Use tail -n 1000 ~/.battery/*/log instead.

Additional context (optional)

I tried disabling the built in battery optimizer and from the CLI told it to discharge to 80 and it laptop went to sleep:

% battery discharge 80
02/24/23-09:11:53 - Discharging to 80% from 88%
02/24/23-09:11:53 - 🔽🪫 Enabling battery discharging
02/24/23-09:11:53 - Battery at 88% (target 80%)
*** sleep *** 

I opened the lid and then set this and it's back to running in clamshell mode:

% battery adapter off && battery charge 80
02/24/23-09:12:09 - Setting adapter to off
02/24/23-09:12:09 - Killing running maintain daemons & enabling charging as default state
02/24/23-09:12:09 - 🔌🔋 Enabling battery charging
02/24/23-09:12:09 - 🔼🪫 Disabling battery discharging
02/24/23-09:12:09 - Battery at 88% ((no remaining), smc charging enabled
02/24/23-09:12:09 - 🔼🪫 Disabling battery discharging
02/24/23-09:12:10 - Killing running maintain daemons & enabling charging as default state
02/24/23-09:12:10 - 🔌🔋 Enabling battery charging
02/24/23-09:12:10 - 🔼🪫 Disabling battery discharging
02/24/23-09:12:10 - Battery at 88% (attached; remaining), smc charging enabled
02/24/23-09:12:10 - Setting adapter to on
02/24/23-09:12:10 - Killing running maintain daemons & enabling charging as default state
02/24/23-09:12:10 - 🔌🔋 Enabling battery charging
02/24/23-09:12:10 - 🔼🪫 Disabling battery discharging
02/24/23-09:12:10 - Battery at 88% (attached; remaining), smc charging enabled
02/24/23-09:12:10 - 🔽🪫 Enabling battery discharging
02/24/23-09:12:10 - Charging to 80% from 88%
02/24/23-09:12:10 - 🔌🔋 Enabling battery charging
02/24/23-09:12:10 - 🔼🪫 Disabling battery discharging
02/24/23-09:12:10 - 🔌🪫 Disabling battery charging
02/24/23-09:12:10 - Charging completed at 88%

I suspect something is going on with the discharge setting.

@cholcombe973
Copy link
Author

Maybe a potential solution for this is to have some code in place to detect when clamshell mode is on: https://unix.stackexchange.com/questions/11724/how-to-detect-a-laptop-hibernate-resumeclose-lid-open-in-osx-from-a-bash-scrip. It looks like a daemon can be registered for a callback to be hit.

@The-Johnson
Copy link

This behavior is caused by the discharging function of the script. When your mac is above 80% battery will force it to use battery power in order to discharge down to <80%. Using battery power disables clamshell mode, due to apple's infinite wisdom that has determined that using clamshell on battery is wildly inappropriate.

To fix this: go to /usr/local/bin/
open battery in your favorite text editor
Find these lines:

# Before we start maintaining the battery level, first discharge to the target level
log "Triggering discharge to $setting before enabling charging limiter"
battery discharge "$setting"
log "Discharge pre battery-maintenance complete, continuing to battery maintenance loop"

Add a # before battery discharge "$setting", like so:
# battery discharge "$setting"

This will disable the discharge behavior of battery, so you will have to manually get it down below 80%, but it will maintain the functionality of clamshell mode.

@actuallymentor
Copy link
Owner

Clamshell users, please try this beta release and thumbs up/down it to let me know if it works for you now!

There is now a new GUI option:

image

@actuallymentor
Copy link
Owner

Closed by release v1.1.4. Please reopen if you have the same issue with that release (with debug info).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants