SMC_breach
- 14 Devlogs
- 24 Total hours
Monitor power usage stats for your mac devices! Planning to support M1 and later
Monitor power usage stats for your mac devices! Planning to support M1 and later
Lately I didn’t make many changes to my code, but I managed to crunch in a solid 5 hours of work.
Did nothing insane infact, these 5 must’ve probably been one of my least unproductive hours so far, but I’ve got to work with what I have, school, family and my hobbies (this thing) and hence it has been a little taxing.
Nonetheless I cleaned up my code, added some comments and built a small flow chart for myself (which I also managed to loose 
But that were my 5hrs pretty much, a mix of organization and anxiety, charge control is still finicky so I’ll try my best to get it right ASAP.
but uhmm, I’ll catch up, promise :)
Peace
Breaching into macs just got EASIER :)
Charging Control now Partially works on my mac, it’s finicky!
It took some inline python, sudo access (yep sudo is needed for charging control) and writing specific flags, since the flags part is something I’m still researching I’d best avoid from naming any stuff too early.
We need superuser-do because at this stage we’re actually breaching in and modifying the system itself and hence permitted and legitemate superuser access is necessary
While I can’t reveal a lot right now since it’s all over the place and I don’t wanna pass on the wrong stuff, I’m getting closer.
Peace.
When it doesn’t work out
pssst, Commented below is the github link if you wanna breach into your Macbook too!
*M1 and later, running macOS Tahoe or greater
yepp, it didn’t work out this time and it’s totally FINE. a few things I learnt along the way, that I thought I might share with you all.
So basically my app SMC_breach has placeholder buttons right now for:
Charge to...
and
Charge Now
both of these serve the purpose of charging control. The idea was simple AF:
Gonna let these buttons speak to Darwin and then write the specific hex values (I suppose that is what you call them unofficially).
Nonetheless after countless tries I failed within that 5 hour timespan, I’m gonna give it a shot again and I love to fail fast because the amount of data and automatic guidance u get is pretty cool! 
Peace.
Insanity
Not only did it cost my sanity but over 3 hours of debugging, talking to the kernel, Gemini Research Mode Chats, and of course 2 hours of Xcode!
If you’ve been out of the loop, this is my project SMC_breach and it
directly talks to macOS and the underlying Darwin kernel to deliver live power usage statistics to you, all that right in the menu bar!
Now my app interfaces with the kernel using private APIs (IOReport), and delivers live metrics that update by the instant!
Now that I’ve tamed her (Darwin kernel) I’m gonna convince her to do nothing actually for now, but my next shot is at the USB ports to get the live incoming and outgoing power data out of doze nutss.
Thanks for checking this out, do rate my project if you enjoy it, be SURE to try it!
Feedback is always appreciated, love y’all for reading till the bottom!
At this point, I’ve managed to get absolute cinema levels of access to
the system.
After extensive research btwn yesterday and tmrw I’ve figured out that
the IOKit framework I yapped about earlier is an absolute tragedy, it’s:
SLOW & USELESS.
The data it provides updates on USB/Magsafe plug & play events or once in 2 minutes or so,
nice for uncs but not for me blud.
Not literally but not metaphorically either. Nonetheless now I’m gonna
have to directly communicate with the Darwin kernel (the main guts of
macOS) to gather all power related data (This might make my app need
sudo) but:
quality > security panic
and it’s open source so you can always see what’s going on under the
hood.
This is me signing off before I sleep! if you read till here, hit follow and we can exchange a couple greetings? won’t ya?
Historically great people have been great problem solvers, and to this day I used to think I was one.
But today my hopes were shattered, because how silly and d*mb can you really get?
I managed to think that my app has some severe error or a Memory leak, that’s causing it to stop at Thread 1 everytime I run it!
I wasted 30mins looking for it, turns out it was just a breakpoint I had set. 
I’m at a loss for words because how do I even speak for myself? 
It’s been 15 hours since my last devlog, had my night’s sleep, completed school, and worked for 3 hours too!
and finally, I think I’m ready to present you with an icon, it’s not perfect, it’s not the best, but it’s my (sub-par) greatest creation.
Presenting - SMC_breach …
Better Animations, better data
The app now let’s you monitor live stats, features better scrolling text animations.
I made sure the app was polling the system every 0.25 seconds, then it was averaging out the 4 data points at 0.25s intervals and giving the user a smooth 1 reading per second. 
This is now complemented by the animations which honestly took a solid amount of trial and error to get right, the key to mastering this was smooth fade out of the numbers, along side using the array chopping for animate per digit’s place! 
My mom keeps calling me dumb occasionally, not that she means any harm, but she might be correct.
I spent 15 minutes trying to figure out why I can’t apply Liquid Glass elements to my app.
Guess what was the issue? can ya?
3…
2…
1…
My dumb ahh forgot that you don’t add .glasseffect() inside of a .background() block.
yepp, that silly it was, but nonetheless Liquid Glass is up and running now.
From here on I gotta figure out how I can make the glass clearer, adjust depth, splay, dispersion. etc etc
The second Image represents my earlier mockup
Probably the only non-coding part here.
First off, I’m kinda in love… with my design.
Not only did I have to spend over an hour tweaking the correct liquid glass settings in Figma, I also I had put all my brain into designing this, trying to get the best of UX and a delight to the eye.
btw a hack for anyone tryna do liquid glass and make it readable, try to spike up the Frost slider in the settings ;)
I’ve also added My Mockup vs Vibecode UI Mockup in the Screenshots!
The next step is gonna be to implement this, and I’m more excited than you think!
As promised through devlog #2 and devlog #3. I now have access to internal data states of macOS.
Currently the power data displayed is correct and alongside is fully functional, now it’s time to switch up the and give it a face-lift.
I’ve also discovered on features like Charge Control and more internal data states mentioned earlier.
I’ll share the facelift soon, the Github code is now live and available with downloads, I’ll share the source in my next devlog.
Thanks for following the journey, do follow it and I’ve got something a lot bigger going on, (a potential AA style title in browser)
As stated in my previous devlog #2, the skeleton UI is now here, I’ve
plugged in all the functions and metrics to gather data but a fix is
needed to make all these display correct values,
for now, we have a correct UpTime status and a correct Adapter Wattage
reading. Other details remain to be fixed.
thanks to the code completion I was able to type out these ~200 lines in under 25 minutes!
This is just theory, but realistically I’m only a couple of hours away from making this true.
Upon extensive research and code review on various online posts and OSS, I was able to find that:
Apple introduced a detailed sub-dictionary within the AppleSmartBattery node on Apple Silicon architectures (M1 and beyond), known as PowerTelemetryData.
The PowerTelemetryData structure yields three critical metrics that must be utilized by my app:
a) SystemPowerIn: This represents the total DC power entering the machine’s logic board directly from the external AC adapter, “prior to any internal routing”.
b) BatteryPower: This metric indicates the precise amount of power actively being routed into the battery for charging, or being pulled from the battery for discharging. (However many projects instead preferred manual calculation using our standard Voltage * InstantAmperage formula, likely for better accuracy?).
c) SystemLoad: This defines the total localized power being consumed internally by the logic board, the System-on-Chip, the display, and all active peripherals.
Stay tuned, I’m finally gonna play with these metrics!
What’s up folks? this is Atharva known online as FiniteCode.
This project is about building a macOS Power Information Utility, wherein the user can view live stats of power consumption and intake for their macbooks (and potentially macs too).
This project is gonna be interesting, this is probably my 3rd or 4th time attempting to work with Swift, it has always been fun.
macOS itself doesn’t natively broadcast a lot of the power information to the Applications, and so you have to go through hidden system APIs.
This is one of the reasons why such Power Management apps are never on the App Store but on sources like Homebrew or Github.
Today I spent over 30minutes setting up my time tracking with Wakatime and connecting it to Stardance metrics, and submitted my IDs for verification.
It was after these basics where I started my research on the hidden APIs I talked about earlier, which for the base for the application, I utilized Gemini and Claude for researching on the same and my findings revealed an IOKitFramework called powermetrics which provides many C functions like:
IOReportCopyChannelsInGroup, IOReportMergeChannels, IOReportCreateSubscription, IOReportCreateSamples, and IOReportCreateSamplesDelta.
The goal will be to use these functions and as much more data as available to build on this app.
I was thinking of making a Cyberpunk-esque design but honestly I’m not sure if I can do this, so we’ll come back to this one some time soon, for now the core focus is on the functionality.
I made the basic menu-bar app and setup Xcode and hence attached some screenshots, feel free to have a look.
Join me in this journey, where I’ll try to make something useful, something fun XD