Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pepa65/bat
Manage battery charge limit
https://github.com/pepa65/bat
battery battery-level battery-life battery-lifespan battery-linux battery-state
Last synced: 5 days ago
JSON representation
Manage battery charge limit
- Host: GitHub
- URL: https://github.com/pepa65/bat
- Owner: pepa65
- License: mit
- Created: 2023-09-26T06:00:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-16T12:20:01.000Z (about 1 month ago)
- Last Synced: 2024-11-16T13:20:52.873Z (about 1 month ago)
- Topics: battery, battery-level, battery-life, battery-lifespan, battery-linux, battery-state
- Language: Go
- Homepage:
- Size: 158 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go Report Card](https://goreportcard.com/badge/github.com/pepa65/bat)](https://goreportcard.com/report/github.com/pepa65/bat)
[![GoDoc](https://godoc.org/github.com/pepa65/bat?status.svg)](https://godoc.org/github.com/pepa65/bat)
![Continuous Integration](https://github.com/pepa65/bat/actions/workflows/ci.yaml/badge.svg)# bat v0.16.1
**Manage battery charge limit*** Repo: github.com/pepa65/bat
* After: github.com/tshakalekholoane/bat
* License: MIT
* Required: Linux-5.4-rc1+ systemd-244+
```
bat v0.16.1 - Manage battery charge limit
Repo: github.com/pepa65/bat
Usage: bat
Options (every option except 's[tatus]' needs root privileges):
[s[tatus]] Display charge level, limit, health & persist status.
[l[imit]] Set the charge limit to percent.
p[ersist] Persist the charge limit after driver reloads.
r[emove] Do not persist the charge limit after driver reloads.
h[elp] Just display this help text.
v[ersion] Just display version information.
The battery with regex 'BAT.' in environment variable BAT_SELECT will be used.
```## About
The goal is to replicate the functionality of the [ASUS Battery Health Charging](https://www.asus.com/us/support/FAQ/1032726/) utility for ASUS laptops on Windows which aims to prolong the battery's life-span 1 2.* Linux kernel module: `asus_nb_wmi`
* System variables used: `/sys/class/power_supply/BAT?/`
* Persist states for `systemd`: `hibernate`, `hybrid-sleep`, `multi-user`, `sleep`, `suspend`, `suspend-then-hibernate`## Requirements
* **Linux kernel version later than 5.4-rc1** which is the [earliest version to expose the battery charge limit variable](https://github.com/torvalds/linux/commit/7973353e92ee1e7ca3b2eb361a4b7cb66c92abee).
* To persist the battery charge limit setting after restart/hibernation/wake-up, the application relies on **[systemd](https://systemd.io/) version 244 or later** (bundled with most current Linux distributions).## Disclaimer
This has been reported to only work with some ASUS and [Lenovo ThinkPad](https://github.com/tshakalekholoane/bat/discussions/23) laptops. For Dell Lattitude/Precision laptops, use package smbios-utils: `smbios-battery-ctl --set-custom-charge-interval=50 80`. For other manufacturers there is also [TLP](https://linrunner.de/tlp/).## Installation
Precompiled binaries (Linux x86_64) are available from the [GitHub releases page](https://github.com/pepa65/bat/releases), download the [latest here](https://github.com/pepa65/bat/releases/latest/download/bat).```shell
sudo wget -qO /usr/local/bin/bat "gitlab.com/pepa65/bat/-/jobs/artifacts/main/raw/bat?job=building"
sudo chmod +x /usr/local/bin/bat
```Alternatively, the application can be build from source by running the following command in the root directory of this repository. This requires a working version of [Go](https://golang.org/):
`CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w"`
To install, do: `sudo mv bat /usr/local/bin` (requires root privileges).
You can also rename the binary to something else if another program with the same name already exists.Or install by simply: `go install github.com/pepa65/bat@latest`
## Examples
### Print the current battery charge level, limit and status
`bat`Sample output:
```
[BAT0]
Level: 45%
Limit: 80%
Health: 85%
Status: Charging
Persist: yes
```### Set a battery charge limit in percentage points (requires privileges):
`sudo bat 80`Sample output:
```
[BAT1] Charge limit set, to make it persist, run:
bat persist
```### Undo the battery charge limit (requires privileges):
`sudo bat 0`Sample output:
```
[BATC] Charge limit unset
```### Persist the currently set charge limit after restart/hibernation/wake-up (requires privileges):
`sudo bat persist`Sample output:
```
[BATT] Persistence enabled for charge limit: 80
```### Remove the persist config settings (requires privileges):
`sudo bat remove`Sample output:
```
[BAT0] Persistence of charge limit removed
```### Remove persist config settings for BAT1 (requires privileges):
`sudo BAT_SELECT=BAT1 bat remove`Output:
```
[BAT1] Persistence of charge limit removed
```