Idea [Action when Power Adapter Removed]

Just a moment Luke,

does this work?

display dialog (do shell script "/usr/bin/pmset -g ps | /usr/bin/head -n 1 | /usr/bin/cut -d \\' -f 2")

Yea sort of.
But it dose not tell me if i take the charger out. when i fist open it it says Ac Power but it dose not tell me if i unplug it .thanks luke

Of course not. It’s just the line to get the information which kind of power is used.
Try my first scripts with the changed line

property flag : true

on run
   set flag to word 1 of (do shell script "/usr/bin/pmset -g ps | /usr/bin/head -n 1 | /usr/bin/cut -d \\' -f 2") is "AC"
end run

on idle
   set ACpower to word 1 of (do shell script "/usr/bin/pmset -g ps | /usr/bin/head -n 1 | /usr/bin/cut -d \\' -f 2") is "AC"
   if flag then
       if ACpower is false then
           beep
           say "power adaptor removed"
           set flag to false
       end if
   else
       if ACpower then set flag to true
   end if
   return 5
end idle

or

on idle
   if word 1 of (do shell script "/usr/bin/pmset -g ps | /usr/bin/head -n 1 | /usr/bin/cut -d \\' -f 2") is not "AC" then
       beep
       say "power adaptor removed"
       quit me
   end if
   return 5
end idle

Jolly Good Show
Thank you very much this script works :smiley: i don’t know how i can repay you. thankyou
Sorry or the long reply also.

Thank you very much!
Im gonna turn this in to a app.
Thanks StefanK! And THe Other Person. But mainly StefanK. Thanks

Thanks Luke

property flag : true

on run
   set flag to word 1 of (do shell script "/usr/bin/pmset -g ps | /usr/bin/head -n 1 | /usr/bin/cut -d \\' -f 2") is "AC"
end run

on idle
   set ACpower to word 1 of (do shell script "/usr/bin/pmset -g ps | /usr/bin/head -n 1 | /usr/bin/cut -d \\' -f 2") is "AC"
   if flag then
       if ACpower is false then
           beep
           say "power adaptor removed"
           set flag to false
       end if
   else
       if ACpower then set flag to true
   end if
   return 5
end idle