- Copy this Zap into your Zapier account and connect your Slack account: https://zapier.com/shared/532ac667d67cd8fceefccc83cc2169488679056d
- Copy both files above into your Mac's
$HOME/Library/LaunchAgents
- 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 - Replace [USERNAME] in
local.slackstatus.plist
with your user account name - Run
launchctl load -w ~/Library/LaunchAgents/local.slackstatus.plist
- ???
- Profit
Last active
November 17, 2021 09:23
-
-
Save tjarksaul/826eeb398e3c7e98924ae29e18b79948 to your computer and use it in GitHub Desktop.
Slack Status Automatization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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