https://github.com/vasilescur/mah-battery
Adds a mAh battery indicator to the Mac bar.
https://github.com/vasilescur/mah-battery
Last synced: 3 months ago
JSON representation
Adds a mAh battery indicator to the Mac bar.
- Host: GitHub
- URL: https://github.com/vasilescur/mah-battery
- Owner: vasilescur
- License: other
- Created: 2019-02-10T16:59:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-11T00:45:37.000Z (over 6 years ago)
- Last Synced: 2025-01-16T17:34:16.566Z (4 months ago)
- Language: Swift
- Homepage:
- Size: 213 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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
...
## 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:```swift
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:
```swift
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:
```swift
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