Skip to content

Instantly share code, notes, and snippets.

@AGresvig
Last active June 5, 2018 12:47
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 AGresvig/ff269904abdb7826be9f54c9ab4d7d71 to your computer and use it in GitHub Desktop.
Save AGresvig/ff269904abdb7826be9f54c9ab4d7d71 to your computer and use it in GitHub Desktop.
A command line utility for changing your Slack status.
#!/bin/bash
# Usage: slackstatus "My new status"
function slackstatus() {
slacktoken=$SLACK_OAUTH_TOKEN
apiurl="https://slack.com/api/users.profile.set?token="$slacktoken"&profile="
emoji=":mag:"
if [ $# -eq 0 ]
then
status=""
emoji=""
else
status="$@"
fi
curl --silent --data-urlencode "profile={\"status_text\":\"$status\",\"status_emoji\": \"$emoji\"}" $apiurl > /dev/null
echo "Status changed to $status"
}
export -f slackstatus > /dev/null
@AGresvig
Copy link
Author

AGresvig commented Jun 5, 2018

Thanks to @samervin for inspiration.
This script uses Slack API to change status (https://api.slack.com/docs/presence-and-status). I use it to set my status to "Focusing" when I start a pomodoro-like app called Focus on my Mac.

To set this up.
You'll need to set your last name, as well as get a token from https://api.slack.com/docs/oauth-test-tokens

To use, type slackstatus . To reset your status (to just your last name), just type slackstatus with no arguments.

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