Battery Notifier is a simple GoLang-based utility that monitors battery levels and sends notifications when the battery is low, critically low, or overcharged. It supports local notifications and optional push notifications via ntfy.sh.
- Notifies when the battery is low (default: 20%)
- Notifies when the battery is critically low (default: 10%)
- Notifies when the battery is overcharged while plugged in (default: 80%)
- Plays a sound notification (configurable)
- Supports push notifications via ntfy.sh
- Configurable check intervals
- Automatically generates a default configuration file
- Cross-platform support (Linux and Windows)
- GoLang 1.24.1 or later (for building from source)
libnotify(for local notifications)- Audio libraries for sound playback (requirements for beep/oto packages)
- GoLang 1.24.1 or later (for building from source)
# Clone the repository
git clone https://github.com/akryptic/battery-notifier.git
cd battery-notifier
# Build the application
go build -o battery-notifier
# Linux: Move the binary to a directory in your PATH
sudo mv battery-notifier /usr/local/bin/
# Windows: The build produces battery-notifier.exe
# Move it to your preferred locationTo reduce the binary size, you can use UPX. UPX is a free, portable, extendable, high-performance executable packer. For more details on how to use UPX, please refer to its GitHub repository.
Battery Notifier uses a configuration file located at:
~/.config/battery-notifier/config.toml
%APPDATA%\battery-notifier\config.toml
If this file does not exist, the application will generate a default configuration.
# Battery threshold settings
low_battery = 20
critical_battery = 10
overcharge_limit = 80
# Notification settings
enable_sound = true
low_sound_file = "" # Optional: path to custom sound for low battery (leave empty to use default)
overcharge_sound_file = "" # Optional: path to custom sound for overcharge alert (leave empty to use default)
sound_volume = 80 # Volume level (0-100)
# Interval settings
check_interval = 60 # Time in seconds between battery status checks (min: 1, max: 300)
# ntfy.sh settings (leave empty if not using ntfy)
ntfy_topic = ""
ntfy_server = "https://ntfy.sh"
ntfy_access_token = "" # Optional: for private topicsbattery-notifierAdd this line to your hyprland.conf:
exec-once = battery-notifier &Create a new service file at /etc/systemd/system/battery-notifier.service:
[Unit]
Description=Battery Notifier Service
After=network.target sound.target
[Service]
Environment=DISPLAY=:0
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/YOUR_USER_ID/bus
Environment=XDG_RUNTIME_DIR=/run/user/YOUR_USER_ID
ExecStart=/usr/local/bin/battery-notifier
Restart=on-failure
User=YOUR_USERNAME
[Install]
WantedBy=graphical.targetReplace YOUR_USERNAME with your actual username, and YOUR_USER_ID with your user ID. You can find your user ID by running:
id -uReload the systemd daemon and enable the service:
systemctl daemon-reload
systemctl enable battery-notifier.service
systemctl start battery-notifier.serviceCheck the status of the service:
systemctl status battery-notifier.serviceNote: This systemd configuration is specific to the user specified in the service file. If you have multiple users who need battery notifications, you'll either need to create separate service files for each user or consider using user-specific systemd services instead.
- Open Task Scheduler (search for "Task Scheduler" in the Start menu)
- Click "Create Basic Task..."
- Enter a name (e.g., "Battery Notifier") and description
- Select "When I log on" as the trigger
- Select "Start a program" as the action
- Browse to the location of your battery-notifier.exe
- Click "Finish"
Method 1: Startup Folder
- Press
Win + Rto open the Run dialog - Type
shell:startupand press Enter - Create a shortcut to your battery-notifier.exe in this folder
Method 2: Registry
- Press
Win + Rto open the Run dialog - Type
regeditand press Enter - Navigate to
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run - Right-click in the right pane and select New > String Value
- Name it "Battery Notifier"
- Set the value to the full path to your battery-notifier.exe
Method 3: Batch Script + Shortcut
- Create a batch file (e.g.,
start_battery_notifier.bat) with the following content:@echo off start "" "C:\path\to\battery-notifier.exe"
- Create a shortcut to this batch file in your startup folder (
shell:startup) - Set the shortcut to run minimized
# Local notification test (with sound if enabled)
battery-notifier --test
# Print current battery status
battery-notifier --read
# Send a test notification via ntfy.sh (requires ntfy_topic in config)
battery-notifier --ntfy
# Reset config to default values
# USE CAREFULLY
battery-notifier --reset
# Execute a single check without continuous monitoring
battery-notifier --dry-runThis project is licensed under the MIT License.
Contributions and suggestions are welcome! Feel free to open an issue or submit a pull request.