-
Notifications
You must be signed in to change notification settings - Fork 7
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
Update for Big Sur/Monterey. Supports Apple Silicon. #12
Conversation
1. Updated battery details for Big Sur and later. 2. ManufactureDate is now calculated differently. 3. Additionally, calculating health and percentage remaining is more precise using AppleRawMaxCapacity and AppleRawCurrentCapacity, than using the regular CurrentCapacity and MaxCapacity.
Adding a new gradient icons set for the workflow. Also updated the readme with an attribution list for the creators.
1. Integrated zenopopovici's code in the issue tracker comments to provide mouse, trackpad and keyboard support. 2. Changed CELLS code to be compatible with Python3 (still works with Py2).
1. Silenced grep on MTK searches, since grep will fail if they are not connected. This causes Alfred to default to its fallback options. 2. Also updated MTK stats to Py3.
Added in some easy code to dynamically pick the icon set based on a command-line argument. (AWP made some automated changes to the files, so committing them as is).
In my opinion this PR should not be merged with the exception of the use of Also, the Python command can lead to a total of nine 9 dots instead of the expected 10. |
I just maintained what the original author had with writing to info.txt and pulling the information from there, rather than querying Additionally, I am not sure where the original icon set was obtained from, since they appear to be part of a set. I tried to match most of it, but I could not find trackpad gradient icons very readily. I am open to suggestions. I thought they looked nicer. If you have any suggestions for icons sets, I will look them up. Could you elaborate on the shell-check issues? I don't see what I have done differently than the original code and there were no comments about shell-check issues there? It is my first time contributing to something, so I am more than happy to learn. :) |
1. Made changes to the Python code to show 10 circles instead of the 9 being shown earlier. 2. Updated icons for serial, trackpad and health to match the color scheme of the other ones. That is the closest I could get for the trackpad. Will update if I find anything better.
The original method invokes
I think your icon set will look good if you manage to get a complete consistent scheme. Btw, your last commit message mentions a trackpad icon but you haven't added it.
ShellCheck is a linter for shell scripts. Please, make sure your workflow is ShellCheck compliant before submitting a PR. Also, you need to update Lastly, after updating README with the new image of the workflow I recommend you to remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you adding the Alfred-Worklow
library to the repo?
This is very weird. I see the code now and for some reason, when I forked and imported it, the text file was being written to. I did wonder the same when I was modifying things, but then left it to the original author's judgment. Guess I had the older version stashed away somewhere and both interfered with each other when I was testing it in my synced folder. I will fix it accordingly. Now what you are saying makes more sense. Note to self: be more careful of your dev environment in the future.
Apologies. I could not find a trackpad icon that matches the scheme. For now, I have re-used the trackpad icon from the regular icon set. It is slightly out of place, but much better than what was present before I feel. I will copy the png from the other directory into this one too.
I was not aware that it had to be shell-check compliant before submitted things. My first PR, learning curve. :)
Will do.
Understood. By the way, I need some clarification about the whole contributing process, in general. What I am doing currently is forking and cloning locally, making changes, packaging using AWP and then importing it into Alfred to test and debug. After all this is done, I commit and push and initiate the PR. It appears to me that your last set of comments don't fall into my workflow (or I am doing it wrong in some manner), since you indicate modifying something in the workflow editor and removing the bundle. Could you please elaborate on what I need to change in my workflow? P.S: Thanks for all the inputs by the way. |
Placeholder trackpad icon till I find a consistent set.
I now see what you mean. I was totally not aware of this. I am going to fix all these issues and re-submit a commit in a while. |
Please, remove the |
I think you built your PR using an old version of the workflow. Please, use the latest version and just add the necessary code. It will keep you from reintroducing issues that are already fixed. |
Removing the A4-WF code.
Another thing you have to look into is battery age. It's not working in your PR, at least on my Mac (intel processor). It can be a bit challenging as |
Actually the battery age is working, to the best of my knowledge. That is the code that iStatMenus uses to calculate battery age precisely. Got it from the author. Also, the question you referenced is another way of doing it. ManufactureDate is still present in the ioreg output. The serial number method won't work if Apple randomizes the serial. It will for now though. I need to test it in an Intel MBP though. |
Now I see I get an error in the Python code:
|
1. Re-written most of the code to correct changes introduced due to using an older version of the script. 2. Code has been run through ShellCheck. The only remaining linter messages cannot be changed, because doing what ShellCheck advises you to do messes with the age calculation. 3. Added a missing gradient icon for the "Age" of the battery.
@xilopaint I tested this on an Intel MBP. The age does not calculate because "ManufactureDate" is not present on Intel laptops, which is strange. In any case, I am working on a potential fix, or even re-writing this entire thing in Python because bash does not allow for the flexibility in programming. Let me see what I can come up with and we can go from there. |
Dude, you are not the maintainer of this repo. You cannot decide by yourself to "rewrite the entire thing" without the permission of the author in some language you don't even know if he's familiar with. Btw, the only Python code of your PR was written two times and both don't work. Your last attempt gives me this output: All the circles are wrongly filled. You probably should be using something like this: CELLS=$(/usr/bin/python3 -c "f='●'*(round($CHARGE/10)) + '○'*(round(10-$CHARGE/10)); print(f)") So you get this output with eight filled circles: |
Dude, I understand I can't re-write his contribution. If I do re-write it in Python and get it working, I'll make it "my" repo and make it a different workflow. I just put in that comment because you were looking at the fix for this code and wanted to let you know that I'm looking at other options too.
The author himself acknowledged somewhere in the Apple Silicon bug comments that scraping from ioreg using the script probably wasn't the best approach (FYI<#11 (comment)>). So yeah, I know. I'll fix the Python piece for this and leave it at that.
All the other shell issues have been fixed AFAIK.
Sent from some sort or a mobile device with an autocorrect function that has a mind of its own.
…________________________________
From: Arthur Pinheiro ***@***.***>
Sent: Saturday, May 7, 2022 2:49:41 PM
To: BenziAhamed/alfred-battery ***@***.***>
Cc: adwaraki ***@***.***>; Author ***@***.***>
Subject: Re: [BenziAhamed/alfred-battery] Update for Big Sur/Monterey. Supports Apple Silicon. (PR #12)
@xilopaint<https://github.com/xilopaint> I tested this on an Intel MBP. The age does not calculate because "ManufactureDate" is not present on Intel laptops, which is strange. In any case, I am working on a potential fix, or even re-writing this entire thing in Python because bash does not allow for the flexibility in programming. Let me see what I can come up with and we can go from there.
Dude, you are not the maintainer of this repo. You cannot decide by yourself to "rewrite the entire thing" without the permission of the author in some language you don't even know if he's familiar with.
Btw, the only Python code of your PR was written two times and both don't work.
Your last attempts gives me this output:
[Screen Shot 2022-05-07 at 16 41 18]<https://user-images.githubusercontent.com/11052366/167269397-43659f06-f6fb-4c14-8c39-e2f49c57ffdb.png>
All the circles are wrongly filled. You probably should be using something like this:
CELLS=$(/usr/bin/python3 -c "f='●'*(round($CHARGE/10)) + '○'*(round(10-$CHARGE/10)); print(f)")
So you get this output with eight circles filled:
[Screen Shot 2022-05-07 at 16 46 57]<https://user-images.githubusercontent.com/11052366/167269543-ac4e2665-b40e-4e90-ac8d-5b990f7ee127.png>
—
Reply to this email directly, view it on GitHub<#12 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA2ZYWQPPT3UM5EFKH5QNB3VI3CNLANCNFSM5VG2RVUA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Actually my participation in this thread aims to avoid a bad PR being merged for a workflow that I use. I didn't try to fix the M1 bug because I don't have a M1 machine.
He talked about scraping from
Not true. You've broken the workflow for me with your change in the |
|
Thanks @adwaraki for putting in the effort to raise this PR, and @xilopaint for the engaging review. I'll close this PR because
PS: As for the original icons - I created those myself using Sketch a long long time ago 🙂 |
Updated battery details for Big Sur and later.
ManufactureDate is now calculated differently.
Additionally, calculating health and percentage remaining is more precise using AppleRawMaxCapacity and AppleRawCurrentCapacity, than using the regular CurrentCapacity and MaxCapacity.