Set your Slack status, presence and do-not-disturb from the shell.
If you are the current on-call, get a random status:
on-call
here: here and not snoozed (dnd off). No status, unless you are on-callaway: away and snoozed (dnd on) for 24 hours. If on-call, no snoozingzzz: here and snoozed (unless you are on-call)
Some other (maybe) useful statuses:
lunch: away and snoozed for 1 hour. Random status of ๐ ๐ ๐ฎ ๐ฅช ๐ฏ Eating lunchbrb: away and snooze for 5 minutes. ๐ถ afk brbdog: away and snooze for 20 minutes. :walking-the-dog: afk brbmeet: here and snoozed. ๐ In a meetingcall: here and snoozed. ๐ On a callpom: here and snooze for 25 minutes. Useful for pomodoro.
other commands:
st: get the current status, skipping cachestc: get the cached status (cache lives for 5 minutes)moon: a trip to the moon ๐auto: run this in a cronjob to check if you are using the camera and setmeetaccordingly
-
Make sure
curl,jq,jo,pgrepare available in your$PATH -
Create a new Slack App from scratch
-
Grant your app the following OAuth scopes:
- users.profile:read
- users.profile:write
- users:read
- users:write
- dnd:read
- dnd:write
-
Install the app to your Workspace to get the OAuth token (probably need admin approval for this step, so ask nicely)
-
Get the necessary environment variables
SLACK_USER_IDfromhttps://<your-org>.slack.com/account/profileSLACK_TOKENfrom step 4 abovePD_USER_IDfromhttps://<your-org>.pagerduty.com/usersPD_TOKENfrom My Profile > User Settings > Create API User TokenPD_SHEDULE_IDfromhttps://<your-org>.pagerduty.com/schedules
-
Set the env vars:
export SLACK_USER_ID="your-slack-id" export SLACK_TOKEN="your-slack-token" export PD_USER_ID="your-pagerduty-id" export PD_TOKEN="your-pagerduty-token" export PD_SHEDULE_ID="your-pagerduty-schedule-id"
Run the script for usage instructions:
$ ./slack.sh
To run in a cronjob, you can use a tmux session with your env vars in it:
* 10-18 * * 1-5 tmux send -t cron "/path/to/slack.sh auto" ENTER > /dev/null 2>&1
To put your slack status in your tmux bar, do something like:
set-option -g status-right "\
#[fg=colour15, bg=colour240]\
#[fg=colour13, bg=colour237] #(/path/to/slack.sh stc) \
#[fg=colour15, bg=colour240]"
You may want to set an alias if are lazy and hate typing, like me:
alias sl='/path/to/slack.sh'