Last active
September 10, 2022 00:37
-
-
Save dnicolson/020fb88d72ac071f2a97a129a067e3a8 to your computer and use it in GitHub Desktop.
Check battery level of Apple Watch via Cloud Battery and display notification if fully charged
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
#!/bin/bash | |
check_battery() { | |
shortcuts run 'Save Apple Watch Battery Level' | |
FILENAME="$HOME/Library/Mobile Documents/iCloud~is~workflow~my~workflows/Documents/AppleWatchBattery.txt" | |
LEVELS=(`tail -2 "$FILENAME"`) | |
if [[ ${LEVELS[1]} -eq 100 && ${LEVELS[1]} -gt ${LEVELS[0]} ]]; then | |
shortcuts run 'Apple Watch Fully Charged' | |
rm "$FILENAME" | |
fi | |
} | |
while true; | |
do | |
check_battery; | |
sleep 60; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment