Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Script by Toggi3.  Use/modify as you please.
  2. -- You need to add this script as a recurring Launchd job for this to work
  3. -- I run a command every 30 seconds as /usr/bin/osascript /path/to/batterywarning.applescript
  4.  
  5. set Cap to (do shell script "ioreg -w0 -l | grep ExternalChargeCapable")
  6. tell Cap to set {wallPower} to {last word of paragraph 1}
  7.  
  8. if wallPower = "Yes" then
  9.         return 0
  10. else
  11.         set Cap to (do shell script "ioreg -wO -l | grep Capacity")
  12.         tell Cap to set {Available, Max} to {last word of paragraph 2, last word of paragraph 1}
  13.         set Pct to round (100 * Available / Max)
  14.  
  15.         if Pct <= 4 then
  16.                 set volume 100
  17.                 do shell script "say -v \"Zarvox\" \"LOW BATTERY\" "
  18.                 if Pct <= 3 then
  19.                         beep 5
  20.                         do shell script "say -v \"Zarvox\" \"PLUG ME IN NOW DUMB ASS\""
  21.                 end if
  22.         end if
  23. end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement