Skip to content

Instantly share code, notes, and snippets.

@dnicolson
Last active September 10, 2022 00:37
Show Gist options
  • Save dnicolson/020fb88d72ac071f2a97a129a067e3a8 to your computer and use it in GitHub Desktop.
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
#!/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