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

Does not discharge when it should #265

Open
sclsj opened this issue Apr 17, 2024 · 3 comments
Open

Does not discharge when it should #265

sclsj opened this issue Apr 17, 2024 · 3 comments

Comments

@sclsj
Copy link

sclsj commented Apr 17, 2024

What is the issue? (required)
battery does nothing when set to 80% but currently at 100%

What exactly did you do to produce the issue? (required)
Steps to reproduce the behavior:
I accidentally made/executed a fork bomb on my computer during computer science class but managed to kill it. battery didn't work properly since. I tried reinstalling and restarting the launchd task.

Expected behavior (required)
Discharge to /Users/jin/.battery/maintain.percentage which is 80.

Error logs

battery logs
👾 Battery CLI logs:

04/17/24-14:07:15 - Not triggering discharge as it is not requested
04/17/24-14:07:15 - Charging to and maintaining at 80% from 100%
04/17/24-14:07:15 - Charge above 80
04/17/24-14:07:15 - 🔌🪫 Disabling battery charging
04/17/24-14:07:15 - 💡 Setting magsafe color to green
04/17/24-14:08:01 - Not triggering discharge as it is not requested
04/17/24-14:08:01 - Charging to and maintaining at 80% from 100%
04/17/24-15:49:36 - Debug trail. User: jin, config folder: /Users/jin/.battery, logfile: /Users/jin/.battery/battery.log, file called with 1: maintain_synchronous, 2: recover
04/17/24-15:49:36 - Recovering maintenance percentage 80
04/17/24-15:49:36 - Not triggering discharge as it is not requested
04/17/24-15:49:36 - Charging to and maintaining at 80% from 100%

🖥️  Battery GUI logs:

tail: /Users/jin/.battery/gui.log: No such file or directory

📁 Config folder details:

total 32
drwxr-xr-x    6 jin   staff   192B Apr 17 14:07 .
drwxr-x---+ 793 jin   staff    25K Apr 17 15:53 ..
-rwxr-xr-x    1 jin   staff   779B Apr 17 15:54 battery.log
-rwxr-xr-x    1 jin   staff     6B Apr 17 14:08 battery.pid
-rw-r--r--    1 jin   staff     3B Apr 17 14:08 maintain.percentage
-rw-r--r--    1 root  staff   897B Apr 17 14:07 visudo.tmp

⚙️  Battery data:

04/17/24-15:54:09 - Battery at 100% (0:00 remaining), smc charging disabled
04/17/24-15:54:09 - Your battery is currently being maintained at 80%
Battery CLI utility v1.1.6

tail -n 1000 ~/.battery/*/log did not work. I think you meant tail -n 1000 ~/.battery/*log

Additional context (optional)

jin@Joy-MBP ~> battery status
04/17/24-15:55:12 - Battery at 100% (0:00 remaining), smc charging disabled
04/17/24-15:55:12 - Your battery is currently being maintained at 80%

jin@Joy-MBP ~ [1]> ps -ef | grep battery
  501 45634     1   0  2:08PM ??         0:00.16 /bin/bash /usr/local/bin/battery maintain_synchronous 80
  501 54204     1   0  3:49PM ??         0:00.02 /bin/bash /usr/local/bin/battery maintain_synchronous recover
  501 55227 55138   0  3:55PM ttys089    0:00.00 grep -i battery

jin@Joy-MBP ~> launchctl list | grep battery
54204	128	com.battery.app
-	0	com.apple.menuextra.battery.helper


jin@Joy-MBP ~> /bin/bash /usr/local/bin/battery maintain_synchronous 80
04/17/24-15:56:19 - Not triggering discharge as it is not requested
04/17/24-15:56:19 - Charging to and maintaining at 80% from 100%

/bin/bash /usr/local/bin/battery maintain_synchronous recover
04/17/24-15:56:31 - Debug trail. User: jin, config folder: /Users/jin/.battery, logfile: /Users/jin/.battery/battery.log, file called with 1: maintain_synchronous, 2: recover
04/17/24-15:56:31 - Recovering maintenance percentage 80
04/17/24-15:56:31 - Not triggering discharge as it is not requested
04/17/24-15:56:31 - Charging to and maintaining at 80% from 100%

jin@Joy-MBP ~> battery discharge 80
04/17/24-11:47:02 - Discharging to 80% from 100%
04/17/24-11:47:02 - 🔽🪫 Enabling battery discharging
04/17/24-11:47:02 - Battery at 100% (target 80%)
04/17/24-11:48:02 - Battery at 100% (target 80%)
04/17/24-11:49:03 - Battery at 100% (target 80%)
04/17/24-11:50:03 - Battery at 100% (target 80%)
04/17/24-11:51:03 - Battery at 99% (target 80%)
04/17/24-11:52:03 - Battery at 99% (target 80%)
04/17/24-11:53:03 - Battery at 98% (target 80%)
04/17/24-11:54:03 - Battery at 98% (target 80%)
04/17/24-11:55:03 - Battery at 97% (target 80%)
04/17/24-11:56:03 - Battery at 97% (target 80%)
04/17/24-11:57:03 - Battery at 96% (target 80%)
04/17/24-11:58:03 - Battery at 96% (target 80%)
04/17/24-11:59:03 - Battery at 96% (target 80%)
04/17/24-12:00:03 - Battery at 95% (target 80%)
04/17/24-12:01:03 - Battery at 95% (target 80%)
04/17/24-12:02:03 - Battery at 94% (target 80%)
04/17/24-12:03:03 - Battery at 94% (target 80%)
04/17/24-12:04:03 - Battery at 93% (target 80%)
04/17/24-12:05:03 - Battery at 93% (target 80%)
04/17/24-12:06:04 - Battery at 92% (target 80%)
04/17/24-12:07:04 - Battery at 92% (target 80%)
04/17/24-12:08:04 - Battery at 91% (target 80%)
04/17/24-12:09:04 - Battery at 91% (target 80%)
04/17/24-12:10:04 - Battery at 90% (target 80%)
04/17/24-12:11:04 - Battery at 90% (target 80%)
04/17/24-12:12:04 - Battery at 89% (target 80%)
04/17/24-12:13:04 - Battery at 89% (target 80%)
04/17/24-12:14:04 - Battery at 88% (target 80%)
04/17/24-12:15:04 - Battery at 88% (target 80%)
04/17/24-12:16:04 - Battery at 87% (target 80%)
04/17/24-12:17:04 - Battery at 87% (target 80%)
04/17/24-12:18:04 - Battery at 86% (target 80%)
04/17/24-12:19:04 - Battery at 86% (target 80%)
04/17/24-12:20:04 - Battery at 85% (target 80%)
04/17/24-12:21:04 - Battery at 85% (target 80%)
04/17/24-12:22:04 - Battery at 84% (target 80%)
04/17/24-12:23:04 - Battery at 84% (target 80%)
04/17/24-12:24:04 - Battery at 84% (target 80%)
04/17/24-12:25:04 - Battery at 83% (target 80%)
04/17/24-12:26:04 - Battery at 83% (target 80%)
04/17/24-12:27:04 - Battery at 82% (target 80%)
04/17/24-12:28:05 - Battery at 82% (target 80%)
04/17/24-12:29:05 - Battery at 82% (target 80%)
04/17/24-12:30:05 - Battery at 81% (target 80%)
04/17/24-12:31:05 - Battery at 81% (target 80%)
04/17/24-12:32:05 - 🔼🪫 Disabling battery discharging
04/17/24-12:32:05 - Discharging completed at 80%

(Note: battery discharge 80 works but then the battery charges back up to 100%.

@sclsj
Copy link
Author

sclsj commented Apr 17, 2024

Also:

/bin/bash /usr/local/bin/battery maintain_synchronous 80 --force-discharge
04/17/24-16:01:23 - Triggering discharge to 80 before enabling charging limiter
04/17/24-16:01:23 - Discharging to 80% from 100%
04/17/24-16:01:23 - 🔽🪫 Enabling battery discharging
/usr/local/bin/battery: line 149: 56229 Killed: 9               sudo smc -k CH0I -w 01
/usr/local/bin/battery: line 149: 56231 Killed: 9               sudo smc -k ACLC -w 01
04/17/24-16:01:24 - Battery at 100% (target 80%)

This happens after the update overwrote my old smc binary (which is properly signed)

@sclsj
Copy link
Author

sclsj commented Apr 17, 2024

The reason is that the smc binary is not signed properly:

jin@Joy-MBP ~> sign /usr/local/bin/smc
/usr/local/bin/smc: valid on disk
/usr/local/bin/smc: satisfies its Designated Requirement

-----------------------------------------------------------------------------

Executable=/usr/local/bin/smc
Identifier=smc
Format=Mach-O thin (arm64)
CodeDirectory v=20400 size=508 flags=0x20002(adhoc,linker-signed) hashes=13+0 location=embedded
Signature=adhoc
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements=none

-----------------------------------------------------------------------------

/usr/local/bin/smc: rejected
默认	16:04:05.571314-0400	kernel	ignoring detached code signature on 'smc' with cdhash '26c8f7a04633a4293136761105669f67087ff6b2' because it is invalid, or not a simple adhoc signature.
默认	16:04:05.571403-0400	kernel	CODE SIGNING: process 56742[smc]: rejecting invalid page at address 0x100b0c000 from offset 0x0 in file "/usr/local/bin/smc" (cs_mtime:1706242396.251094815 != mtime:1713377263.564225975) (signed:1 validated:1 tainted:1 nx:0 wpmapped:0 dirty:0 depth:0)
默认	16:04:05.571441-0400	kernel	smc[56742] Corpse failure, too many 6
默认	16:04:05.571444-0400	kernel	Process[56742] crashed: smc. Too many corpses being created.

@sclsj
Copy link
Author

sclsj commented Apr 17, 2024

My old smc binary is from here: https://github.com/hholtmann/smcFanControl/releases/tag/2.6. That one is properly signed with Developer ID.

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

1 participant