aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: ae8d1fe4aae16bcc4eb9ee4c5c0d5883e3b14075 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# battd

A simple battery daemon written for use with a daemontools-style supervisor.

`run` polls the status of a `check` function with an interleaved call to
`interval`. On the transition from a successful `check` exit status to an
unsuccessful `check` exit status the `failed` function is called.

## Installation

``` text
# ./install /etc/sv/battd
# ln -s /etc/sv/battd /var/service
```

Adjust the above as needed.

## Usage

Configure `conf` appropriately. This should contain three functions:

`interval`
:   Called between consecutive calls to `check`.

`check`
:   Called to determine the battery status.

`failed`
:   Called when the battery status has transitioned from a successful to a
    failing return.

An example `conf` is included and installed alongside the run script. An
included `battcheck` awk script takes two optional arguments and a path to the
uevent file of a battery to determine if the battery capacity and estimated
run-time meet the specified criteria. Multiple invocations of `battcheck` can be
used to handle more complex logic involving multiple batteries.