Skip to content

Send a notification to disconnect the laptop when the battery reaches a certain threshold, thereby optimizing the lifespan of the battery

License

Notifications You must be signed in to change notification settings

thalesorp/BatteryNotifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Battery Notifier

The Battery Notifier is a simple utility that provides real-time notifications about your laptop's battery status. It allows you to set minimum and maximum battery levels, and it will notify you when your battery charge falls below the minimum or exceeds the maximum level.

Table of Contents

Installation

  1. Download or clone this repository to your local machine.

  2. Open a PowerShell console with administrator privileges.

  3. Navigate to the directory where you have downloaded/cloned this repository.

  4. Run the following command to import the module:

    Import-Module .\BatteryNotifier.psm1

Usage

To start receiving battery notifications, use the Start-BatteryNotifier function. It will continuously monitor your laptop's battery status and display notifications when the battery reaches your defined minimum and maximum levels.

Start-BatteryNotifier

You can customize the minimum and maximum battery levels as well as the notification image using the provided functions (see Configuration).

Configuration

The Battery Notifier module uses a JSON settings file to store configuration information. If the settings file does not exist, default values will be used.

  • MaxBattery: The maximum battery charge percentage at which you want to be notified (default: 80).
  • MinBattery: The minimum battery charge percentage at which you want to be notified (default: 20).
  • NotificationImagePath: The path to a custom notification image (default: null).

To configure these settings, use the following functions:

  • Set-MaxBattery: Set the maximum battery charge percentage for notifications.
  • Set-MinBattery: Set the minimum battery charge percentage for notifications.
  • Set-NotificationImage: Set a custom notification image.

Example:

# Set the maximum battery level to 90%
Set-MaxBattery -maxBattery 90

# Set the minimum battery level to 10%
Set-MinBattery -minBattery 10

# Set a custom notification image
Set-NotificationImage -notificationImagePath "C:\path\to\image.jpg"

Functions

Start-BatteryNotifier

Starts monitoring the laptop's battery status and displays notifications based on the configured minimum and maximum battery levels.

Set-MinBattery

Sets the minimum battery charge percentage for notifications. Takes an integer value between 0 and 100 as input.

Set-MinBattery -minBattery 15

Set-MaxBattery

Sets the maximum battery charge percentage for notifications. Takes an integer value between 0 and 100 as input.

Set-MaxBattery -maxBattery 85

Set-NotificationImage

Sets a custom notification image. Takes a valid image file path (JPG, JPEG, PNG, GIF, BMP, ICO) as input.

Set-NotificationImage -notificationImagePath "C:\path\to\image.jpg"

Contributing

Contributions to this project are welcome! If you find any issues or have suggestions for improvements, please open an issue or create a pull request.

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute it according to the terms of the license.

About

Send a notification to disconnect the laptop when the battery reaches a certain threshold, thereby optimizing the lifespan of the battery

Resources

License

Stars

Watchers

Forks

Packages

No packages published