Skip to content

Commit

Permalink
docs: add homebrew-related steps in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie0129 committed Oct 8, 2024
1 parent a7fedaf commit 50e7ecf
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,37 @@ Yes, macOS have optimized battery charging. It will try to find out your chargin

> Currently, it is command-line only. Some knowledge of the command-line is recommended. A native GUI is possible but not planned. If you want to build a GUI, you can ask me to put a link here to your project
You have two choices to install `batt`:

1. Homebrew
2. Installation Script

You can choose either one. Please do not use both at the same time to avoid conflicts.

### Homebrew

1. `brew install batt`
2. `sudo brew services start batt`
3. Please read [Notes](#notes).

### Installation Script

1. (Optional) If you are lazy, there is an installation script to help you get the first 3 steps done (Internet connection required). Put this in your terminal: `bash <(curl -fsSL https://github.com/charlie0129/batt/raw/master/hack/install.sh)`. You may need to provide your password (to control charging). This will download and install the latest _stable_ version for you, then you can skip to step 5.
<details>
<summary>Manual installation steps</summary>

2. Get the binary. For _stable_ and _beta_ releases, you can find the download link in the [release page](https://github.com/charlie0129/batt/releases). If you want development versions with the latest features and bug fixes, you can download prebuilt binaries from [GitHub Actions](https://github.com/charlie0129/batt/actions/workflows/build-test-binary.yml) (has a retention period of 3 months and you need to `chmod +x batt` after extracting the archive) or [build it yourself](#building) .
3. Put the binary somewhere safe. You don't want to move it after installation :). It is recommended to save it in your `$PATH`, e.g., `/usr/local/bin`, so you can directly call `batt` on the command-line. In this case, the binary location will be `/usr/local/bin/batt`.
4. Install daemon using `sudo batt install`. If you do not want to use `sudo` every time after installation, add the `--allow-non-root-access` flag: `sudo batt install --allow-non-root-access`. To uninstall: please refer to [How to uninstall?](#how-to-uninstall)
</details>

5. In case you have GateKeeper turned on, you will see something like _"batt is can't be opened because it was not downloaded from the App Store"_ or _"batt cannot be opened because the developer cannot be verified"_. If you don't see it, you can skip this step. To solve this, you can either 1. (recommended) Go to System Preferences -> Security & Privacy -> General -> Open Anyway; or 2. run `sudo spctl --master-disable` to disable GateKeeper entirely.
6. Test if it works by running `sudo batt status`. If you see some status info, you are good to go!
7. Time to customize. By default `batt` will set a charge limit to 60%. For example, to set the charge limit to 80%, run `sudo batt limit 80`.
8. As said before, it is _highly_ recommended to disable macOS's optimized charging when using `batt`. To do so, open _System Preferences_, go to _Battery_, and uncheck _Optimized battery charging_.

Notes:
### Notes

- Test if it works by running `sudo batt status`. If you see some status info, you are good to go!
- Time to customize. By default `batt` will set a charge limit to 60%. For example, to set the charge limit to 80%, run `sudo batt limit 80`.
- As said before, it is _highly_ recommended to disable macOS's optimized charging when using `batt`. To do so, open _System Preferences_, go to _Battery_, and uncheck _Optimized battery charging_.
- If your current charge is above the limit, your computer will just stop charging and use power from the wall. It will stay at your current charge level, which is by design. You can use your battery until it is below the limit to see the effects.
- You can refer to [Usage](#usage) for additional configurations. Don't know what a command does? Run `batt help` to see all available commands. To see help for a specific command, run `batt help <command>`.
- To disable the charge limit, run `sudo batt limit 100`.
Expand Down Expand Up @@ -166,20 +186,36 @@ I want a _simple_ tool that does just one thing, and **does it well** -- limitin

### How to uninstall?

Script-installed:

1. Run `sudo batt uninstall` to remove the daemon.
2. Remove the config by `sudo rm /etc/batt.json`.
3. Remove the `batt` binary itself by `sudo rm $(where batt)`.

Homebrew-installed:

1. Run `sudo batt disable` to restore the default charge limit.
2. Run `sudo brew services stop batt` to stop the daemon.
3. Run `brew uninstall batt` to uninstall the binary.
4. Remove the config by `sudo rm /opt/homebrew/etc/batt.json`.

### How to upgrade?

Automatic:
Script-installed:

> Updates to the latest _stable_ version. If you want to use other versions (_beta_, _development_), please use the manual method.
```bash
bash <(curl -fsSL https://github.com/charlie0129/batt/raw/master/hack/install.sh)
```

Homebrew-installed:

```bash
brew upgrade batt
sudo brew services restart batt
```

Manual:

1. Run `sudo batt uninstall` to remove the old daemon.
Expand Down

0 comments on commit 50e7ecf

Please sign in to comment.