Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@AGresvig 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