A production-ready GNOME 50+ battery indicator extension with intelligent notifications, persistent settings, and a modern preferences interface.
- π DBus Battery Monitoring: Real-time battery level monitoring via UPower DBus interface
- βοΈ Persistent Settings: All configuration persists across GNOME Shell restarts using GSettings
- π Intelligent Notifications:
- Low battery alert when level drops below 40% (and not charging)
- High battery alert when level reaches 80% or above (while charging)
- ποΈ Left-Click Toggle: Instantly enable/disable notifications
- π Context Menu: Right-click for quick access to Notifications toggle and Settings
- β° Smart Cooldown: Configurable notification cooldown (default 30 seconds)
- π Hysteresis: Prevents notification spam near threshold boundaries
- π¨ Visual Feedback: Real-time icon updates reflect notification status
- π₯οΈ Modern Preferences: GTK4/libadwaita preferences window with immediate settings sync
- π GNOME 50+ Compatible: Stable integration with GNOME Shell 50+
The extension must be installed to:
~/.local/share/gnome-shell/extensions/batteryind@ash.ext.com/
This is the standard location where GNOME Shell looks for user extensions.
-
Clone or download this repository:
git clone https://github.com/ash-baseplate/BatteryInd.git
-
Copy the extension to your local extensions directory:
cp -r BatteryInd ~/.local/share/gnome-shell/extensions/batteryind@ash.ext.com/Note: The folder name
batteryind@ash.ext.commust match the UUID inmetadata.json -
No restart required! The extension will load automatically when enabled.
-
Enable the extension:
gnome-extensions enable batteryind@ash.ext.com
-
Install GNOME Extensions Manager if you haven't already:
sudo apt install gnome-shell-extension-manager
-
Copy the extension to the extensions directory (step 2 from Method 1)
-
Open Extensions Manager and enable "Battery Indicator"
- Toggle Notifications: Left-click the battery indicator icon in the top panel to instantly enable/disable
- Context Menu: Right-click to open a menu with:
- Notifications On/Off toggle (synchronized with left-click state)
- Settings button to open preferences
- Visual Status:
- Green icon: Notifications enabled
- Gray icon: Notifications disabled
Open the preferences window from the extension menu (right-click β Settings) or from GNOME Extensions manager. You can configure:
- Notification Cooldown: Time (in seconds) between consecutive notifications for the same condition
- Lower Limit: Battery percentage that triggers low battery alert (default 40%)
- Upper Limit: Battery percentage that triggers charging alert (default 80%)
Settings apply immediately without requiring a restart.
- Low Battery (< 40%): Get notified when battery is low and not charging
- High Battery (β₯ 80%): Get notified when battery is high and still charging
- Smart Cooldown: Respects the configured cooldown timer between successive alerts
- Hysteresis Protection: Uses a 5% margin above/below thresholds to prevent rapid-fire notifications near boundaries
- Real-Time Evaluation: Checks battery state immediately when settings change or timer fires
This extension is tested and compatible with:
- GNOME Shell 50+
batteryind@ash.ext.com/
βββ extension.js # Main extension logic and panel indicator
βββ prefs.js # GTK4/libadwaita preferences window
βββ metadata.json # Extension metadata and compatibility
βββ lib/
β βββ battery-settings.js # Settings schema keys and validation helpers
β βββ battery-monitor.js # DBus-based UPower battery monitor
βββ schemas/
β βββ org.gnome.shell.extensions.batteryind.gschema.xml # GSettings schema
β βββ gschemas.compiled # Compiled schema binary
βββ icons/ # Custom icons
β βββ on.png # Notifications enabled icon
β βββ off.png # Notifications disabled icon
βββ README.md # This file
- Settings Backend: Uses GSettings for persistent, dconf-backed configuration
- Battery Monitoring: Direct DBus proxy to org.freedesktop.UPower.Device for real-time state updates
- Notification Logic: Time-based cooldown with hysteresis to prevent spam
- Preferences UI: Native GTK4 with libadwaita for consistent GNOME appearance
- GNOME 50 Compatibility: Preserves required event handling workarounds for stable panel integration
This extension promotes good battery health practices:
- Default 40% Low Threshold: Prevents deep discharge cycles that can damage lithium-ion batteries
- Default 80% High Threshold: Avoids keeping batteries at 100% charge, which can reduce long-term capacity
- Customizable: Adjust thresholds to match your device and usage patterns
- Lightweight: Minimal system resource usage with DBus callbacks, not polling
- Adaptive Polling: Secondary polling interval matches cooldown for efficient re-evaluation
- Non-blocking: Uses GLib timeouts and DBus signals for fully asynchronous operation
- Memory Efficient: Single DBus proxy connection with set-based callback management
-
Check if the extension is enabled:
gnome-extensions list --enabled | grep batteryind -
Check for errors in the logs:
journalctl -f -o cat /usr/bin/gnome-shell
-
Restart GNOME Shell:
# On X11 killall -3 gnome-shell # On Wayland (requires logout/login) gnome-session-quit --logout
Settings should update in real-time. If they don't:
- Check that the preferences window closed properly
- Verify the extension is still enabled
- Try restarting GNOME Shell (see above)
-
Ensure notifications are enabled in GNOME Settings:
- Open Settings β Notifications
- Make sure notifications are enabled
-
Check if the extension icon shows notifications are enabled (green icon)
-
Verify configured thresholds match your test conditions (default: < 40% or β₯ 80%)
-
Ensure the cooldown timer has expired since the last notification
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Test the extension thoroughly
- Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is open source. Feel free to use, modify, and distribute as needed.
Ash Baseplate
- GitHub: @ash-baseplate
- Repository: BatteryInd
- Major Refactor: Rebuilt from scratch for GNOME 50+ with modern architecture
- Persistent settings using GSettings (no manual config files)
- Modern GTK4/libadwaita preferences window
- DBus-based UPower battery monitoring (replaces spawned UPower commands)
- Context menu with toggle and settings button
- Real-time settings application without restart
- Improved notification cooldown with proper time-based re-evaluation
- Hysteresis logic to prevent notification spam near thresholds
- Configurable notification cooldown and battery thresholds
- GNOME 50+ only (dropped support for older versions)
- Initial release
- Basic battery monitoring and notifications
- Toggle functionality for enabling/disabling notifications
- Support for GNOME Shell 43-48
β If you find this extension useful, please consider giving it a star on GitHub!