Skip to content

Commit

Permalink
PauseSlackNotifications: First commit (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka authored Nov 20, 2021
1 parent c1b6c28 commit efcdc42
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ _Requires Keyboard Maestro 6+._

## Actions

- [Clean Clipboard with TextSoap](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/clean-clipboard-with-textsoap)
- [Clean Plain Text with TextSoap](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/clean-plain-text-with-textsoap)
### BetterTouchTool

- [Display BetterTouchTool HUD](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/display-bettertouchtool-hud)

### Slack

- [Pause Slack Notifications](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/pause-slack-notifications)
- [Post to Slack](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/post-to-slack)
- [Set Slack Availability](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/set-slack-availability)
- [Set Slack Status](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/set-slack-status)

### TextSoap

- [Clean Clipboard with TextSoap](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/clean-clipboard-with-textsoap)
- [Clean Plain Text with TextSoap](https://github.com/mirka/keyboard-maestro-plugin-actions/tree/master/src/clean-plain-text-with-textsoap)

## Download

Download from the [latest release](https://github.com/mirka/keyboard-maestro-plugin-actions/releases/latest).
Expand Down
43 changes: 43 additions & 0 deletions src/pause-slack-notifications/Keyboard Maestro Action.plist
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>
27 changes: 27 additions & 0 deletions src/pause-slack-notifications/README.md
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%`.
7 changes: 7 additions & 0 deletions src/pause-slack-notifications/default.sh
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
Binary file added src/pause-slack-notifications/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit efcdc42

Please sign in to comment.