Skip to content

Instantly share code, notes, and snippets.

@graceac
Created May 31, 2018 06:12
Show Gist options
  • Save graceac/64e5ec4cda02f5ab5a142f0fcd17ca10 to your computer and use it in GitHub Desktop.
Save graceac/64e5ec4cda02f5ab5a142f0fcd17ca10 to your computer and use it in GitHub Desktop.
Set Slack Status Automatically
-- Set Slack Status v0.1
-- // NEXT ACTIONS
-- ✔ Add if so I can have both working remotely and office set automatically (wifi?)
-- Have an automator rule so meetings on calendar are automatically set as well (possible) need to watch calendar events probably
-- Integrate with pomodoro to show Busy on Slack and when I'll be available
-- Create default settings for usual locations so its easier to update
set wifiName to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'"
--return wifiName
tell application "Slack"
activate
tell application "System Events"
-- quick launch prompt (cmd-K)
key code 40 using {command down}
delay 0.5
-- enter “grace” to switch to #grace DM
keystroke "grace"
delay 0.3
-- press of the return or enter key
key code 36
delay 0.3
if wifiName = "ACHOME_2.4G" then
set the clipboard to "/status :house_with_garden: Working Remotely"
else if wifiName = "Danfoss Mobile" then
set the clipboard to "/status :office: A424"
-- this part should trigger the prompt for "Where are you working from?" only if on a different Wifi then my home wifi and Danfoss Mobile. But it does not work properly yet.
else if wifiName ≠ {"ACHOME_2.4G", "Danfoss Mobile"} then
set theLocation to display dialog "Where are you working from?" default answer "" with icon note buttons {"🏢 A424", "🏡 Working Remotely", "🚌 Commuting"} default button "🏡 Working Remotely"
set the clipboard to "/status (text returned of theResponse)"
end if
-- paste the text from clipboard into the field (cmd-V)
key code 9 using {command down}
delay 0.3
-- press of the return or enter key
key code 36
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment