Skip to content
Adds a mAh battery indicator to the Mac bar.
Swift
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
mAh Battery.xcodeproj
mAh Battery
Battery.swift
BatteryAPI.swift
LICENSE.md
README.md

README.md

mAh Battery

Adds a mAh (milliampere-hours) battery level indicator to the Mac bar.

This meme was created by the 4:00 AM gang.

By the way this is totally a joke, it's the first thing I ever wrote in Swift. lol gotem

Screenshot

Get it cause the screen was shot

...

screenshot

How Do I Use It?

  • Prerequisites:
    • XCode
    • A MacBook
    • a will to live
  1. Clone the repository.
  2. Open the project in XCode.
  3. Press ⌘ R (Command + R) to run, or use the Build option from the menu.
  4. Install the generated .app file into your Applications folder.
  5. Go to System Preferences > Users and Groups > Login Items, click +, and add the app.
  6. Hold and drag the little thing to wherever your little heart desires.

Why Does this Exist?

Why does anything exist? Does anything exist? 🤔 *cmatrix intensifies*

How Does it Work?

Poorly.

JK. It works pretty well. It's very simple, too:

I blatantly copied some code from God-knows-where and put it in Battery.swift, then wrote the BatteryAPI as a completely un-necessary frivolity to interface with it, with a series of highly complicated and useful functions such as:

func isCharging() -> String {
    return String(battery.isCharging());
}

Yeah that's right. I use semicolons in Swift.

Oooh. Aaah.

Basically it's a bunch of menuitems with an update function that does this:

statusItem.button?.title = batteryApi.currentCapacity(unit: true);
currentCapacityOutlet.title = "Current Capacity: " + batteryApi.currentCapacity();
maxCapacityOutlet.title = "Maximum Capacity: " + batteryApi.maxCapacity();
...

On a timer that looks like this:

Timer.scheduledTimer(
    timeInterval: 5, 
    target: self, 
    selector: #selector(StatusMenuController.timerFire), 
    userInfo: nil, 
    repeats: true
);

Contributing

Nah. I mean, if you really want to, I won't stop you. But there are probably many better things to do with your time.

License

This software is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License. 'Cause it's the CC license with the coolest name :) And also 'cause they say not to use it for code, and I'm that guy.













end my suffering

You can’t perform that action at this time.