GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tomtastic/MagicPowerAlert: Better alerts when your Apple mouse or keyboard is getting low on power.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

42 Commits
42 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
MagicPowerAlert.sh
MagicPowerAlert.sh
 
 
README.md
README.md
 
 
example.jpg
example.jpg
 
 

Repository files navigation

MagicPowerAlert

Convenient low-battery notification for your Apple Mac with Bluetooth devices.

Mac OS warns your Magic Mouse is running out of power at 2%. Not ideal given the charging port location. MagicPowerAlert lets you know at 35% by default, giving you lots of time to fit in a charging session at a time of your choosing.

Competency level: comfortable using Terminal, and cron.

Instructions:

Download Code
$ mkdir MagicPower
$ cd MagicPower
$ curl -L0 -O https://raw.githubusercontent.com/thisdougb/MagicPowerAlert/master/MagicPowerAlert.sh

View Battery and Charging Status (without the pop-up alert)

$ ./MagicPowerAlert.sh status
Magic Keyboard with Numeric Keypad at 98%
Magic Mouse 2 at 47% (charging)

Configure

The default should be fine, it'll pick up either mouse or keyboard below 35% power. But you can change this is you like.

# Set to mute consecutive alerts for a period of minutes. Makes it practical to schedule
# MagicPowerAlert to run frequently, say every 30 minutes. Really, two alerts per day are
# probably enough of a reminder. So a good value is maybe 4 hours.
MUTE_CONSECUTIVE_ALERTS_HOURS=4

# Inactivity detection. If user is afk, don't continue and possibly spam the desktop with alerts.
# For example, no alerts during the night when running other automated tasks.
INACTIVITY_THRESHOLD_MINS=5

# You can change the message, if coffee is not your thing.
MESSAGE="Get a coffee and charge:"

Test Pop-up Alert

Give it a quick test, set the alert THRESHOLD to 100 by supplying as an argument. A window prompt should pop-up, with your alert.

$ chmod +x MagicPowerAlert.sh
$ ./MagicPowerAlert.sh 100

Remember that running while muted will not pop-up an alert. So just remove this file if you want to re-test.

$ ls -l MagicPowerAlert.sh.mute
-rw-r--r--  1 dougb  staff  0  4 Apr 11:29 MagicPowerAlert.sh.mute

Schedule It

If you haven't used cron before, then the relevant info (from 'man 5 cron') is:

The time and date fields are:

       field         allowed values
       -----         --------------
       minute        0-59
       hour          0-23
       day of month  1-31
       month         1-12 (or names, see below)
       day of week   0-7 (0 or 7 is Sun, or use names)

A field may be an asterisk (*), which always stands for first-last.

To specific a range use 9-12, which gives 9, 10, 11, 12.

To step through a range use */<step>, for example */5 will give 0, 5, 10, etc.

Add a cron entry with your file path and time preferences. To avoid waking up to a hundred pop-up alerts, ensure you configure muting and inactivity to suitable values.

For example, this runs every 30 minutes:

*/30 * * * * /Users/dougb/dev/MagicPowerAlert/MagicPowerAlert.sh

Switch Off

Of course you can delete the cron entry, or simply comment it out.

# switched off
#*/30 * * * * /Users/dougb/dev/MagicPowerAlert/MagicPowerAlert.sh

About

Better alerts when your Apple mouse or keyboard is getting low on power.

Resources

Readme
GPL-3.0 license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.