Dead-simple battery monitor for Linux.
Find a file
2024-01-11 23:43:27 +03:00
.github/workflows CI: build with go 2024-01-11 22:56:10 +03:00
internal officially rename package to batmon 2024-01-11 23:38:08 +03:00
nix cleanup 2024-01-11 23:43:27 +03:00
vendor provide vendor dir for nix 2024-01-11 23:37:32 +03:00
.envrc cleanup 2024-01-11 23:43:27 +03:00
.gitignore go rewrite 2024-01-11 22:51:07 +03:00
example.config.json go rewrite 2024-01-11 22:51:07 +03:00
flake.lock cleanup 2024-01-11 23:43:27 +03:00
flake.nix cleanup 2024-01-11 23:43:27 +03:00
go.mod officially rename package to batmon 2024-01-11 23:38:08 +03:00
go.sum officially rename package to batmon 2024-01-11 23:38:08 +03:00
LICENSE Initial commit 2024-01-08 19:13:35 +03:00
main.go officially rename package to batmon 2024-01-11 23:38:08 +03:00
README.md cleanup 2024-01-11 23:43:27 +03:00

🔋 Batmon

Batmon is a dead-simple battery monitor for Linux written in Go. It provides real-time monitoring of battery status and adjusts the power profile accordingly to optimize battery life.

Features

  • Real-time monitoring of battery status
  • Adjustment of power profile based on battery status
  • Support for custom commands and extra commands
  • Configuration via a JSON file
  • Not written in Rust (the codebase is readable)

Installation

Prerequisites

  • Upower
  • powerprofilesctl
  • Nix or Go

Nix

Batmon is primarily distributed through a Nix flake. You may install it manually using nix profile install github:NotAShelf/batmon

Manually

go install . # this will install Batmon in your $GOPATH

Usage

To start using Batmon, use the following command:

batmon

By default, Gomon will load the configuration from config.json in the current directory. You can specify a different configuration file using the --config flag:

batmon -c /path/to/config.json

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:

{
  "batPaths": [
    {
      "path": "/sys/class/power_supply/BAT0",
      "command": "powerprofilesctl set performance",
      "extraCommand": "echo 'Battery is charging' | wall"
    }
  ]
}
  • You can leave command empty to use the default behaviour - which will switch active powerprofile using powerprofiles set performance | balanced

  • extraCommand, if provided, will be executed in addition to the command value.