Dead-simple battery monitor for Linux.
Find a file
2024-01-11 23:37:32 +03:00
.github/workflows CI: build with go 2024-01-11 22:56:10 +03:00
internal go rewrite 2024-01-11 22:51:07 +03:00
nix go rewrite 2024-01-11 22:51:07 +03:00
vendor provide vendor dir for nix 2024-01-11 23:37:32 +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.nix go rewrite 2024-01-11 22:51:07 +03:00
go.mod go rewrite 2024-01-11 22:51:07 +03:00
go.sum go rewrite 2024-01-11 22:51:07 +03:00
LICENSE Initial commit 2024-01-08 19:13:35 +03:00
main.go go rewrite 2024-01-11 22:51:07 +03:00
README.md go rewrite 2024-01-11 22:51:07 +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:

gomon -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.