Use one AppleScript to toggle on and off (1 or 0)
To get the state I would use something like:

set sms to (do shell script"pmset -g |grep \"sms\" | awk '{print $2}'")


Then:

if sms is "0" then
  do shell script"pmset -a sms 1" with administrator privileges
else
  do shell script"pmset -a sms 0" with administrator privileges
end if


Note the "administrator privileges"  this is used  because you will not be able to use 'sudo' because there will be no interface for you to type your password.

The "administrator privileges" will display a Normal OS Authentication dialogue for you to enter the user name and password.