-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support MacOS #26
Comments
Here I am. As I said, I am very happy to collaborate with you. Thank you very much for your willingness!
I have to do some tests on the script created by @ldan93 but, in my opinion, it should be possible to set arbitrary thresholds.
@ldan93 uses the following steps:
I think it should be possible pass some arbitrary values to |
From what I have understood, there's no straightforward way (using that script) to set, for example, 35-75 or 56-71 (i.e. totally arbitrary values for both high and low as long as low<high). Having such a possibility would be ideal, and make the applet adaptation much less of a hassle.
I need to read into all of this more, I'm totally unfamiliar with the whole Basically, here's what I have in mind as an algorithm:
Actually, this is how it currently works on Linux. Figuring out the command (set of commands) for 1. is the first step (and half the job, really). |
Hello @nekr0z and @profzei
|
Perfect, we'll do that.
Yep, I've already toyed with this idea. Doable, but too many moving parts, I'd prefer some other alternative. |
So, I've written a basic ACPI Method (DGB5) in SSDT-RMDT.aml It takes the XXYY0000 argument as an input. |
Is there a reasonable expectation of where |
Well, currently I put |
I think if we can't really rely on |
Well, About avoiding using |
About getting the current thresholds, I've investigated the process of parsing system logs. Even if it's not the best path, this is achievable with this script I wrote :
|
OK, I'm getting close to hacking up a crude prototype, but my lack of MacOS knowledge starts showing. Please enlighten me, because I'm kinda lost here.
|
Positive answer! (we can put
I tried to look at into my ioreg but I didn't find any useful info about battery thresholds maybe because I didn't look for the "right entry" |
That's good. Makes it actually feasible to use
Would you mind patching your In other news: I've been able to compile If someone has Go installed, I'd appreciate if you tried to clone this repository, check out the |
On my computer, with macOS 10.15, it builds but it doesn't run/put the icon in the tray... I have attached the build logs and the output of |
Thank you so very much! It's awesome that you have Go set up, your help in debugging is priceless. Looks like we're hitting a known issue with the systray library. It only manifests on OS X. Since your behaviour is the same as mine, I can further debug this one by myself. But first let's get at least something working. I've pushed some new code to the What's supposed to happen is for the applet to do all the steps from |
You're welcome ! I've been thinking about something else : I used your applet in Linux before switching to MacOs. I've just remembered that there was an option to tweak Fn-Lock. I definitely think I could quite easily add relevant ACPI methods in the SSDT-RMDT to get and set Fn-Lock state, so we could also implement this later on. |
@ldan93 thanks again! We're closing in. I've been trying to nail that systray issue, but with no luck yet. I still have a couple of ideas to try, so not all is lost (yet). For now I've simply disabled the applet mode for OS X (i.e. it's always I've pushed more code, and would appreciate a final test. If I got it right, it should parse the thresholds, paint a window and even allow setting the thresholds. If I made a mistake somewhere (which is totally possible and actually likely) and something doesn't work, I'd appreciate the |
Totally. If battery thresholds work, implementing FnLock control will be a piece of cake. All I need is:
|
Ok, I was finally able to make the applet mode work. Unfortunately, with these libraries on OS X there seems to be no way to have a window drawn and the systray at the same time, so no custom threshold settings for the applet mode, sorry. Should work in the windowed mode, though. |
Thank you so much !! Seeing this project materialising at such a great pace is so cool ! So, the applet mode is drawn as expected and the applet is able to set the thresholds. Here are some observations :
|
Oops, missed that one. Should be working with the latest code.
Not really. :) Try again? |
|
Actually, there used to be the same issue with the linux driver, and we even have code to mitigate it. That has long been obsolete, as the linux driver was fixed by Ayman, but the code is still there. I activated it for OS X, should to the trick.
I wouldn't really know, MacOS is not really my realm. ;) From what I gathered so far, I need to make something called an App Bundle, which should be relatively straightforward to do. I was planning on figuring this out as soon as we have the applet really working, so it looks like that's what I'll be doing next. The plan is to have a build script option to generate that App Bundle thing when building for MacOS. |
There is a small issue that I forgot to report :
When I wrote my first hacky script, I actually noticed the same strange behaviour : setting thresholds to 0-100 and then reading them would report an unreliable output... Apart from that, everything is working really nice, thanks again for your wonderful work 👍 |
@ldan93 The applet uses the log trick to report thresholds (as you might have already guessed). Since the log doesn't show the protection is off, the applet can't guess it. On Linux the driver always reports the thresholds as 0-100 or 0-0 when battery protection is off, and that's how the applet figures it out. We either need to set the thresholds to those values as part of switching the protection off, or else we need some command or a log trick for the applet to probe whether the protection is off. Currently for setting the thresholds the applet uses your DBG5 method, except for actually for switching it off, which is done by calling your DBG0 method. Looks like the DBG0 method, while turning the protection off, fails to change the thresholds that later get reported in the log. I noticed that it has |
Setting 0-0 doesn't do the trick... About the DBG0 method : actually, we should not use this one, this was a very bad implementation I wrote... Because of the "Sleep" function in the ACPI code, it makes the Matebook freeze for one second. Just using the DBG5 method with 0 - 100 values (so the argument would be Then, I've done some reverse engineering on the EC registry. I think we've got a way of knowing whether battery protection is OFF or ON :
|
Nope. Well, maybe your model is an exemption, but on all MateBooks I've seen, including mine, that one is for "charging allowed/disallowed". If your protection is on, it will be |
OK then, this was a bad guess, never mind... |
You did it manually via DBG5, right? Not via the applet? Because the applet wouldn't really do that for now.
OK, will change. |
Yep ! Setting it to 0 strangely resets the thresholds to 40-70... |
Could you please open a Terminal and type-in the following command : Then, while keeping this process running, open another terminal instance (new window or tab), and type in one by one the following commands :
After that, go back to the first terminal (with the log stream process). Kill the process with CTRL+C. You should have a log.txt file in you home directory (or wherever you were when you launched the log stream command). |
@profzei the applet relies on the information in the log to read the battery values and the Fn-Lock state. Since you have everything properly loaded (or so I understood from the previous messages), my first (and only, actually) logical guess is something is switched off in the logging system itself, so that the messages ACPIDebug sends to the logging system don't end up in the log. @ldan93 may have more ideas, but I know too little about MacOS to be of any help in solving this particular mistery. |
@nekr0z Yes I agree with you: it's completely clear. But, as I said, my install should be standard so this "issue" could be relevant also for many other users interested in this applet... |
@profzei Absolutely! |
Sorry, misclicked. |
@ldan93 |
To check if it's just a problem of log tracing, can you tell us whether Can you also try to :
I don't remember changing something in config.plist other than adding I must say that, from what I remember, I just followed Rehabman's readme EDIT : I don't know what is you current kext loading order, but if that's not already the case, can you try to load ACPIDebug as the very last kext ? |
OK, so I've done some research. I think there's a problem with macOS Big Sur and ACPI_Debug.kext log feature. Here is what I've tried :
@profzei Can you perform the same There is at least another GitHub issue where someone wasn't able to get logs from ACPI Debug with Big Sur. The kext hasn't been updated since 2015, but it worked with all macOS versions since then, we are very unlucky... |
@ldan93 I followed your steps for Console, but nothing is traced in Console.app with |
@ldan93 I'll do it probably this night... Do you think |
There is one difference: you are loading
Me too...
Done: nothing changed... Good news about
|
I already asked, but looks like it got lost:
Maybe there is a less hacky way to read the values than messing up with the logs after all. Long shot, I know... |
@profzei Thanks for your debugging. It looks like ACPI calls made by ioio are still effective but the log feature is broken in Big Sur. So we have to find another way... |
@ldan93 the objects named |
@nekr0z @ldan93 With Therefore I put in my I opened a Terminal and typed-in one by one the following commands checking every time what I got with
This is what I got respectively:
ioio -s org_rehabman_ACPIDebug dbg7 0
ioio -s org_rehabman_ACPIDebug dbg5 1677721600
ioio -s org_rehabman_ACPIDebug dbg4 0
ioio -s org_rehabman_ACPIDebug dbg1 0
@ldan93 With the last command battery stopped charging... is it normal? |
@nekr0z Please find the requested ioreg results : ioreg_logs.zip @profzei Oh, great findings ! Does this bootarg enable you to get these log messages in Console.app (with ACPIDebug search filter) or with the The logs you get with dmesg are totally expected. Tell me if you battery is now charging with these commands... |
...Nope! I cannot see any
Yes! Battery is charging fine... @ldan93 |
@ldan93 @nekr0z @ldan93
Now outputs from commands |
Thank you very much for these new elements. So, we know there is still a way ! It involves some heavy tweaking though... Let's see if we get some feedback from @zhen-zen about other options. Maybe there is a more straightforward / cleaner way to do this. But at least we now have a backup plan. |
@ldan93 Sure!😊👍🏻 |
Hi, Here are some news :
@profzei : do you know what are the differences between loading a kext at boot stage with OpenCore and manually loading the kext ? Could the kext be loaded the same way with OpenCore ? Maybe this is a matter of timing, I don't know... |
@ldan93 Honestly I don't know... but I guess the issue could be due not to a matter of timing (i.e. if a kext is loaded... it is loaded and that's all...) but maybe which path (i.e. local path or EFI path... since I guess that when you load manually |
Well, I think we have to make a decision about the way forward. Here are the possibilities that I see :
|
I skimmed through your discussion with zhen-zhen, and as much as I'd love to take option 1, debugging it (with zhen-zhen's help) requires running OS X on the hardware, and I don't have a spare Matebook to do that. :( |
People are running MacOS on Matebooks, and it looks like
matebook-applet
would be welcome there.It should be relatively easy to add MacOS-specific endpoints and have them probed when running the applet on MacOS. All our dependencies support MacOS, so there shouldn't be a problem.
Two things prevent me from implementing this straight away:
The text was updated successfully, but these errors were encountered: