Skip to content

SharkPlush/Bash-AC-Power-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

NOTE: This is mostly untested, so if you are willing to test or better yet provide fixes / optimizations feel free to do so.

This wrapper is meant to be used in conjunction with a systemd service to wrap around certain service you don't want running while on battery power.

The wrapper doesn't use polling so no extra battery drain will happen while it waits for AC power.

This wrapper should be very adaptive to whatever you need not just systemd.

Examples:

  • Auto updates can be made to "wait" for AC power rather than run on battery power.
  • Backup services can be made to run on AC power only rather than battery.

How the wrapper works:

  1. Wrapper gets executed.
  2. Wrapper check if you device is a PC or a mobile device.
  • If the device is a PC all the battery checking logic gets ignored and executes whatever you need.
  • BUT if the device is a mobile device the wrapper checks if its on AC power or not.
  1. The wrapper checks if the device is on AC power.
  • If the device is on AC power then it will execute whatever you need.
  • If the device is off AC power then it triggers function that will wait for AC power and once it receives AC power it will execute whatever you need.

Main features:

  • PC detection.
  • No polling.
  • Multi-battery laptop support!
  • Multi-AC adapter support.

To install, modify the wrapper to your needs and place it in /usr/local/bin/

In the in the executable I've left comments on where you need to modify for your needs.

As the sole copyright holder, I hereby permanently and irrevocably waive the requirements in Section 3(a)(1)(A)(i) (attribution/credit) and Section 3(a)(1)(B) (indication of modifications) of the CC BY-NC 4.0 license for this work. You are not required to credit me or list any changes, although both are appreciated. All other terms, including the NonCommercial restriction (no commercial use allowed), remain in full effect.

Shield: CC BY-NC 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

CC BY-NC 4.0

About

A universal non polling battery charging detection wrapper for your services

Resources

License

Stars

Watchers

Forks

Languages