MacID for OS X Extension – Set Slack Away

Here’s a small AppleScript extension which will set you as away on Slack when your Mac sleeps (if Slack is running):

on slackIsRunning()
  set isRunning to false
  tell application "System Events"
    set isRunning to (name of processes) contains "Slack"
  end tell
  return isRunning
end slackIsRunning

on setAsAway()
  activate application "Slack"
  tell application "System Events"
    tell process "Slack"
      keystroke "/away "
      keystroke {return}
    end tell
  end tell
end setAsAway

if slackIsRunning() then
end if

It works best if you drop it into MacID’s “onSleep” directory rather than “onLock”. It’s also worth noting that typing /away  in Slack while you’re away will set you as active, so if you’re already set as away this script will do the opposite!

For more information about extending MacID with AppleScript check this post out.

One thought on “MacID for OS X Extension – Set Slack Away”

  1. Thanks for your great app. I love it. I have written my own AppleScript to do thing when MacId lock/unlocks my machine. The question now is…

    Is there a way to control MacId options (e.g. turn proximity wake on/off ) via AppleScript?

Leave a Reply

Your email address will not be published. Required fields are marked *