-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PauseSlackNotifications: First commit (#6)
- Loading branch information
Showing
5 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
43 changes: 43 additions & 0 deletions
43
src/pause-slack-notifications/Keyboard Maestro Action.plist
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Name</key> | ||
<string>Pause Slack Notifications</string> | ||
<key>Script</key> | ||
<string>default.sh</string> | ||
<key>Icon</key> | ||
<string>icon.png</string> | ||
<key>Title</key> | ||
<string>%Param%Notifications% Slack Notifications</string> | ||
<key>Results</key> | ||
<string>None|Window|Briefly|Typing|Pasting|Variable|Clipboard</string> | ||
<key>Parameters</key> | ||
<array> | ||
<dict> | ||
<key>Label</key> | ||
<string>OAuth token</string> | ||
<key>Type</key> | ||
<string>TokenString</string> | ||
</dict> | ||
<dict> | ||
<key>Label</key> | ||
<string>Notifications</string> | ||
<key>Type</key> | ||
<string>PopupMenu</string> | ||
<key>Default</key> | ||
<string>Pause</string> | ||
<key>Menu</key> | ||
<string>Pause|Resume</string> | ||
</dict> | ||
<dict> | ||
<key>Label</key> | ||
<string>Pause duration in minutes</string> | ||
<key>Type</key> | ||
<string>Calculation</string> | ||
<key>Default</key> | ||
<string>60</string> | ||
</dict> | ||
</array> | ||
</dict> | ||
</plist> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Pause Slack Notifications | ||
|
||
Pause or resume notifications on [Slack](https://slack.com/). | ||
|
||
## Download | ||
|
||
Download from the [latest release](https://github.com/mirka/keyboard-maestro-plugin-actions/releases/latest). | ||
|
||
## How to use | ||
|
||
### Get a Slack OAuth access token | ||
|
||
You will first need a Slack OAuth access token with the `dnd:write` scope. | ||
|
||
1. Go to your [Apps page](https://api.slack.com/apps/) and create a new app for your Slack workspace. | ||
2. Go to OAuth & Permissions ▸ Scopes ▸ User Token Scopes. | ||
3. Click the “Add an OAuth Scope” button and add the `dnd:write` scope. | ||
4. Scroll up to the “OAuth Tokens & Redirect URLs” section and click the “Install App to Workspace” button. Complete the install as directed. | ||
5. You should now be able to copy your OAuth access token. | ||
|
||
### Parameters | ||
|
||
- **OAuth token**: Paste your OAuth token here. | ||
- **Notifications**: Whether to pause or resume notifications. | ||
- **Pause duration in minutes**: The number of minutes to pause notifications. This value is required when sending a pause request, but will be ignored for resume requests. | ||
|
||
The action will return the JSON response from the Slack server. If you save this to a variable, for example called `result`, you can easily parse this by using text tokens like `%JSONValue%result.ok%`. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
if [ "$KMPARAM_Notifications" = "Pause" ]; then | ||
curl -s "https://slack.com/api/dnd.setSnooze?token=$KMPARAM_OAuth_token&num_minutes=$KMPARAM_Pause_duration_in_minutes" | ||
else | ||
curl -s "https://slack.com/api/dnd.endSnooze?token=$KMPARAM_OAuth_token" | ||
fi |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.