I'm used to track mine working time with a custom script and I have keyboard shortcut for start and stop actions. One thing the script does is that when I "stop" my work, it sets mine IRC nick to "jhutar_afk" and when I "start" my work it sets the nick back to plain "jhutar". This is e.g. handy taking a launch break or going for some errands. The same is possible with Slack:
I have started with How to set a Slack status from other apps article. It is very easy.
- Create a legacy token (I know, it is legacy - need to investigate how to use current way :-/) and put it to the variable
token='xoxp-0000000000-000000000000-000000000000-00000000000000000000000000000000'
- Construct a json to send:
profile='{"status_text": "Away from keyboard", "status_emoji": ":tea:"}'
- Send that to the API:
curl -X POST https://slack.com/api/users.profile.set --silent --data "profile=$profile" --data "token=$token"
This way I can set various statuses. Then I have realized that what I really want is to set mine presence (that green or empty/black dot next to your nick). That is easy as well:
- Again (see above), prepare your token
token='xoxp-0000000000-000000000000-000000000000-00000000000000000000000000000000'
- Use the Slack API:
curl -X POST https://slack.com/api/users.setPresence --silent --data "presence=away" --data "token=$token"
(to set yourself away) or usepresence=auto
(for a normal mode when Slack decides based on your activity)
Given how long I was avoiding to actually add it to my script, it was very easy at the end :-)