Skip to content

Instantly share code, notes, and snippets.

@jgamblin
Created April 19, 2017 12:39
Show Gist options
  • Save jgamblin/d16a53a6fdeaea76a5579ed17ffba74a to your computer and use it in GitHub Desktop.
Save jgamblin/d16a53a6fdeaea76a5579ed17ffba74a to your computer and use it in GitHub Desktop.
Set your slack status based on Outlook calendar.
launch application "Microsoft Outlook"
launch application "Slack"
property startDate : current date
property endDate : startDate + (10 * minutes)
property cachedStatus : ""
property results : {}
property running : true
global emailAddress
try
emailAddress
on error
display dialog "Email address..." default answer "firstlast@domain.com" with title "Email Address"
set emailAddress to text returned of result
end try
repeat while running
tell application "Microsoft Outlook"
set results to query freebusy exchange account 1 for attendees emailAddress range start time startDate range end time endDate interval 5 as list
set presentStatus to results's last item as string
if presentStatus = cachedStatus then
-- Do nothing
else
if presentStatus = "free" then
tell application "System Events"
tell application "Slack" to activate
key code 18 using {command down}
delay 1
keystroke "/status :computer: Not in a meeting, probably hacking something."
delay 0.5
key code 36
delay 0.3
set visible of process "Slack" to false
end tell
set cachedStatus to "free"
else if presentStatus = "tentative" then
tell application "System Events"
tell application "Slack" to activate
key code 18 using {command down}
delay 1
keystroke "/status :grey_question: I might be in a meeting, I might not be."
delay 0.5
key code 36
delay 0.3
set visible of process "Slack" to false
end tell
set cachedStatus to "tentative"
else if presentStatus = "busy" then
tell application "System Events"
tell application "Slack" to activate
key code 18 using {command down}
delay 1
keystroke "/status :spiral_calendar_pad: In a meeting"
delay 0.5
key code 36
delay 0.3
set visible of process "Slack" to false
end tell
set cachedStatus to "busy"
else if presentStatus = "oof" then
tell application "System Events"
tell application "Slack" to activate
key code 18 using {command down}
delay 1
keystroke "/status :car: Out Of The Office"
delay 0.5
key code 36
delay 0.3
set visible of process "Slack" to false
end tell
set cachedStatus to "oof"
end if
end if
end tell
delay 60
end repeat
@kkarlsen
Copy link

No instructions for this one.
Please elaborate some setup and installation steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment