Last active
June 26, 2017 17:55
-
-
Save xunker/3814f13a62dd71a5dc409cd1b3911e41 to your computer and use it in GitHub Desktop.
Automatically set your Slack status emoji based on what WiFi network you are connected to
This file contains hidden or 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 | |
| # Originally based on https://gist.github.com/samervin/621fcde93d28346ec5dbab4466b51d45 | |
| slacktoken="YOUR_SLACK_TOKEN" | |
| apiurl="https://slack.com/api/users.profile.set?token="$slacktoken"&profile=" | |
| # https://stackoverflow.com/questions/4481005/get-wireless-ssid-through-shell-script-on-mac-os-x | |
| # This will probably only work on Mac OS 10.10+. | |
| ssid=$(/usr/sbin/networksetup -getairportnetwork en0 | cut -c 24-) | |
| echo $ssid | |
| if [ "$ssid" = "WORK_NETWORK_NAME" ]; then | |
| status_emoji=":office:" | |
| elif [ "$ssid" = "HOME_NETWORK_NAME" ]; then | |
| status_emoji=":home:" | |
| else | |
| status_emoji=""; | |
| fi | |
| if [ -z "$status_emoji" ] && [ "${status_emoji+xxx}" = "xxx" ]; then | |
| echo "No status to update" | |
| else | |
| curl --silent --data-urlencode "profile={\"status_emoji\": \"$status_emoji\"}" $apiurl > /dev/null | |
| echo "status_emoji: $status_emoji" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment