Created
February 13, 2022 19:26
-
-
Save dickiedyce/cd2531a1cbf4c862f9d47aae80468a29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Menu: Battery Monitor | |
// Description: Check if AC should be disconnected? Poorman's AlDente | |
// Author: Richard Dyce | |
// Twitter: @dickiedyce | |
// schedule: 0,15,20,45 5-22 * * * | |
import "@johnlindquist/kit" | |
const result = await exec(`pmset -g batt`) | |
const charge = 1 * result.stdout.match(/(\d+)\%/)[1] | |
const state = result.stdout.match(/(discharging|charging)/)[0] | |
const source = result.stdout.match(/(Battery Power|AC Power)/)[0] | |
if(charge > 80 && source == 'AC Power' ) { | |
notify(`UNPLUG! The laptop is ${state} from ${source}, at ${charge}%`) | |
} else if (charge < 40 && source == 'Battery Power') { | |
notify(`PLUG-IN! The laptop is ${state} from ${source}, at ${charge}%`) | |
} else { | |
// notify(`The laptop is ${state} from ${source}, at ${charge}%`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment