Skip to content

Instantly share code, notes, and snippets.

@tjarksaul
Last active November 17, 2021 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjarksaul/826eeb398e3c7e98924ae29e18b79948 to your computer and use it in GitHub Desktop.
Save tjarksaul/826eeb398e3c7e98924ae29e18b79948 to your computer and use it in GitHub Desktop.
Slack Status Automatization
  1. Copy this Zap into your Zapier account and connect your Slack account: https://zapier.com/shared/532ac667d67cd8fceefccc83cc2169488679056d
  2. Copy both files above into your Mac's $HOME/Library/LaunchAgents
  3. Replace the hoook URL in slackstatus.sh with the hook URL you get from Zapier, and replace [OFFICE NETWORK SSID] with your office's network SSID. Also update status emojis and text as you see fit
  4. Replace [USERNAME] in local.slackstatus.plist with your user account name
  5. Run launchctl load -w ~/Library/LaunchAgents/local.slackstatus.plist
  6. ???
  7. Profit
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.slackstatus</string>
<key>ProgramArguments</key>
<array>
<string>/Users/[USERNAME]/Library/LaunchAgents/slackstatus.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/etc/resolv.conf</string>
<string>/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist</string>
<string>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
#!/bin/bash
while [ `date +%H` -gt 17 ] && [ `date +%H` -lt 8 ]
do
sleep 900
done
ssid=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
if [ "$ssid" == "[OFFICE NETWORK SSID]" ]; then
# set status to 'In the office'
curl -X POST --data '{"emoji": ":office:", "text": "HK2"}' https://hooks.zapier.com/hooks/catch/[HOOK_URL]
else
# set status to 'Working remotely'
curl -X POST --data '{"emoji": ":house_with_garden:", "text": "WFH"}' https://hooks.zapier.com/hooks/catch/[HOOK_URL]
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment