Expand description
§BatNo
A battery monitoring library that periodically checks battery status and sends notifications when the battery reaches a configured threshold.
§Extending BatNo
Platform-specific functionality is isolated behind two traits:
BatteryProviderhandles reading battery information.SystemNotifierhandles sending notifications.
To add support for a new operating system:
- Implement
BatteryProviderfor the new platform. - Implement
SystemNotifierfor the platform’s notification system. - Create a constructor that combines those implementations into a
BatteryMonitor.
The monitoring logic does not need to change as long as the new types implement the required traits.
Structs§
- Battery
Monitor - Coordinates battery monitoring and notification handling.
- Linux
Battery - Battery provider implementation for Linux systems.
- Linux
Notifier - Sends desktop notifications using the Linux
notify-sendcommand.
Enums§
- Battery
Status - Represents the current state of a battery.
Traits§
- Battery
Provider - Provides access to battery information.
- System
Notifier - Provides a way to send system notifications.
Functions§
- monitor_
battery - Continuously monitors battery level and sends notifications when required.
- print_
battery_ info - Prints battery information as a formatted table.