BatNo
BatNo is a lightweight Linux utility that monitors your battery level and sends a desktop notification when it falls below a configurable threshold.
Unlike many battery monitoring tools, BatNo is designed to avoid notification spam. Once you've been notified, it won't notify you again until the battery has recharged above a configurable reset threshold.
Why?
Many laptops have an annoying behavior when the charging cable has a loose connection.
Imagine this scenario:
- Your battery reaches 20%.
- BatNo sends a notification reminding you to plug in your charger.
- You connect the charger.
- Because of a loose cable, charging briefly disconnects.
- The battery is still at 20%.
- Another notification appears.
- This repeats every few seconds.
The constant notification spam quickly becomes frustrating.
BatNo solves this by remembering that it has already warned you. After sending a notification, it waits until the battery has charged above a configurable reset threshold before another low-battery notification can be sent.
For example:
- Notification threshold: 20%
- Reset threshold: 25%
Battery: 20% -> Notification sent
Battery: 19% -> No notification
Battery: 18% -> No notification
Battery: 20% -> No notification
Battery: 24% -> No notification
Battery: 25% -> Notification system resets
Battery: 20% -> Notification sent again
Features
- Lightweight
- Reads battery information directly from Linux
sysfs - Uses
notify-sendfor desktop notifications - Prevents repeated notifications
- Configurable monitoring interval
- Configurable notification threshold
- Configurable reset threshold
- Displays battery information in a formatted table
Requirements
- Linux
notify-send(usually provided bylibnotify)- A desktop environment that supports desktop notifications
Installation
One-line installer (recommended)
Install the latest release:
|
By default, BatNo is installed to ~/.local/bin.
If ~/.local/bin is not on your PATH, the installer will let you know and print the command you should add to your shell startup file (e.g. ~/.bashrc or ~/.zshrc).
Custom installation
The installer can be customized using environment variables.
Install a specific release:
VERSION=v1.2.3 |
Install to a different directory:
INSTALL_DIR="/bin" |
Install a specific version to a custom directory:
VERSION=v1.2.3 INSTALL_DIR="/bin" \
|
From crates.io
From source
Clone the repository:
Build:
Run:
Uninstall
If you installed BatNo using the installer script:
|
If you installed BatNo to a custom directory, specify the same INSTALL_DIR that was used during installation:
INSTALL_DIR="/bin" \
|
Note: The uninstall script removes only the
batnobinary. It does not modify your shell configuration or remove the installation directory.
If you installed BatNo with Cargo:
Running BatNo as a background service
BatNo can run continuously in the background using a user-level systemd service.
This requires systemd user services (i.e. systemctl --user must work in your session).
The service starts automatically when you enter your graphical desktop session and keeps monitoring your battery without requiring a terminal window to stay open.
Install the background service
Run:
The installer will:
- Find the installed
batnoexecutable in yourPATH. - Verify that the executable is a valid BatNo installation by running:
- Display the detected installation path and version.
- Ask you to confirm that this is the correct BatNo installation.
- Ask for the monitoring configuration:
- Notification threshold
- Reset threshold
- Monitoring interval
- Create a user-level systemd service.
- Enable and start the service.
Example:
Found BatNo:
Path: /home/user/.local/bin/batno
Version: batno 1.0.0
Is this the correct BatNo installation? [y/N] y
Notification threshold [%] (default 20): 20
Reset threshold [%] (default 25): 25
Monitoring interval in seconds (default 30): 30
How the service works
The service is installed as a user systemd service:
~/.config/systemd/user/batno.service
It runs only for the current user and does not require administrator privileges.
The service:
- Starts automatically when the user enters their graphical desktop session.
- Runs BatNo in the background.
- Restarts automatically if BatNo exits unexpectedly.
- Uses the thresholds and interval configured during installation.
The generated service executes BatNo similar to:
Managing the service
Check the current status:
Stop the service:
Start the service:
Restart the service after changing settings:
View service logs:
Remove the background service
To stop BatNo from running automatically:
|
This will:
- Stop the running BatNo service.
- Disable automatic startup.
- Remove the systemd service file.
- Reload the user systemd configuration.
The BatNo executable itself is not removed. You can still run it manually with:
Security and privacy considerations
The service runs with the same permissions as your user account.
This means:
- BatNo can access anything that your user account can access.
- The service does not run with administrator privileges.
- Installing the service does not require
sudo. - Removing the service does not remove the BatNo binary.
The installer creates a systemd service file containing the exact path to the BatNo executable and the configured command-line arguments. Review the generated service file if you want to verify the configuration:
Only install service scripts from sources you trust. A script executed through:
|
runs with your user permissions and should always be reviewed before use if downloaded from an unknown source.
Usage
Run with default settings:
Show available options:
Example:
Display battery information:
Command-line options
| Option | Default | Description |
|---|---|---|
-m, --monitor-interval <SECONDS> |
30 |
The interval, in seconds, at which the program checks the battery |
-n, --notify-threshold <PERCENTAGE> |
20 |
The battery percentage at or below which the program sends a notification |
-r, --reset-threshold <PERCENTAGE> |
25 |
The battery percentage that must be reached while charging before another low-battery notification can be sent |
-b, --battery-info |
false |
Outputs information about the battery |
-h, --help |
Prints help information | |
-V, --version |
Prints the installed BatNo version |
Extending BatNo
The project separates platform-specific code from the monitoring logic.
Support for new operating systems only requires implementing two traits:
BatteryProviderSystemNotifier
Once these are implemented, a platform-specific constructor can create a BatteryMonitor, and the existing monitoring logic works without modification.
Contributing
Contributions are welcome.
Before contributing, please read the Code of Conduct.
If you'd like to contribute:
- Fork the repository.
- Create a feature branch.
- Make your changes.
- Run
cargo fmt. - Run
cargo clippy. - Open a pull request.
Possible areas for improvement include:
- Windows support
- macOS support
- Additional battery information
- Better notification customization
- Configuration file support
- Automated tests
- CI workflows
- Packaging for Linux distributions
If you find a bug or have an idea for an improvement, feel free to open an issue or submit a pull request.
Roadmap
Possible future improvements include:
- Windows support
- macOS support
- More battery information
- Multiple battery support
- Configuration file
- Custom notification icons
- Logging
- Unit and integration tests
License
Copyright (c) 2026 2happy42
This project is licensed under the GNU Affero General Public License v3.0 or later. See the LICENSE file for details.