batmon/README.md

91 lines
2.1 KiB
Markdown
Raw Normal View History

2024-01-11 19:51:07 +00:00
# 🔋 Batmon
2025-01-08 08:19:16 +00:00
Dead-simple, somewhat configurable battery monitor for Linux. Batmon monitors
the battery path in real time and adjusts your power profiles accordingly to
optimize battery life for e.g. laptops.
2024-01-11 19:51:07 +00:00
## Features
- Real-time monitoring of battery status
2025-01-08 08:19:16 +00:00
- Dynamic adjustment of power profiles
- Simple configuration though JSON configuration file
- Optional command execution on state changes
2024-01-11 19:51:07 +00:00
## Installation
2025-01-08 08:19:16 +00:00
### Prerequisites
2024-01-11 19:51:07 +00:00
- Upower
- powerprofilesctl
- Nix or Go
### Nix
2025-01-08 08:19:16 +00:00
You are strongly encouraged to get Batmon through Nix, using the flake located
in this repository. You may install it manually on non-NixOS systems using
`nix profile install`.
```bash
nix profile install github:NotAShelf/batmon
```
Or on NixOS systems using the package exposed for your system.
```nix
{inputs, pkgs, ...}: {
environment.systemPackages = [
inputs.batmon.packages.${pkgs.stdenv.system}.default
];
}
```
Alternatively, using the NixOS _module_ to install Batmon and configure a
systemd service for you.
```nix
{inputs, pkgs, ...}: {
imports = [inputs.batmon.nixosModules.default];
services.batmon.enable = true;
}
```
2024-01-11 19:51:07 +00:00
### Manually
```console
go install . # this will install Batmon in your $GOPATH
```
2025-01-08 08:19:16 +00:00
Start Batmon through your terminal, or as a systemd service.
2024-01-11 19:51:07 +00:00
2025-01-08 08:19:16 +00:00
## Configuration
2024-01-11 19:51:07 +00:00
2025-01-08 08:19:16 +00:00
By default, Batmon will load the configuration from `config.json` located in the
current directory. You can specify a different configuration file using the
`--config` flag:
2024-01-11 19:51:07 +00:00
```console
2024-01-11 20:43:27 +00:00
batmon -c /path/to/config.json
2024-01-11 19:51:07 +00:00
```
2025-01-08 08:19:16 +00:00
The configuration file should contain a list of batteries to monitor, along with
any custom commands or extra commands to execute. Here's an example of a
configuration file:
2024-01-11 19:51:07 +00:00
```json
{
"batPaths": [
{
"path": "/sys/class/power_supply/BAT0",
"command": "powerprofilesctl set performance",
"extraCommand": "echo 'Battery is charging' | wall"
}
]
}
```
2025-01-08 08:19:16 +00:00
- You can leave `command` empty to use the default behaviour - which will switch
active powerprofile using `powerprofiles set performance | balanced`
2024-01-11 19:51:07 +00:00
- `extraCommand`, if provided, will be executed in addition to the `command`
value.