|
1 | 1 | # ifttt-trigger
|
| 2 | + |
2 | 3 | Trigger ifttt recipes easily from command line
|
| 4 | + |
| 5 | +https://github.com/hossman/ifttt-trigger |
| 6 | + |
| 7 | +## Pre-Reqs |
| 8 | + |
| 9 | +* You must have perl installed, along with the LWP::UserAgent & JSON::XS packages |
| 10 | +* Create an IFTTT account if you don't already have one: http://ifttt.com/ |
| 11 | +* Active the Maker channel: https://ifttt.com/maker |
| 12 | + * Make note of the "key" assigned to you |
| 13 | + * In the Usage examples below we'll assume it's YOUR_LONG_KEY |
| 14 | +* Create a Recipe that uses the Maker channel's "Recieve a web request" trigger |
| 15 | + * Chose an "Event Name" and make note of it |
| 16 | + * In the Usage examples below we'll assume it's EVENT_NAME |
| 17 | + |
| 18 | +## Basic Usage |
| 19 | + |
| 20 | +```bash |
| 21 | +$ ifttt-trigger.pl YOUR_LONG_KEY EVENT_NAME EVENT_NAME "This string will be the 'value1' input to your IFTTT Action" |
| 22 | +``` |
| 23 | + |
| 24 | +```bash |
| 25 | +$ ifttt-trigger.pl YOUR_LONG_KEY EVENT_NAME EVENT_NAME "You may have" "at most three" "input values" |
| 26 | +``` |
| 27 | + |
| 28 | +```bash |
| 29 | +# There's no requirement that any input values be specified if don't need them in your recipe |
| 30 | +$ ifttt-trigger.pl YOUR_LONG_KEY EVENT_NAME EVENT_NAME |
| 31 | +``` |
| 32 | + |
| 33 | +## Suggested Usage |
| 34 | + |
| 35 | +If you have the "IF" App installed on your phone, and an IFTTT recipe that sends notifications to your phone using the message of `{{Value1}}` then you can add something like this to your `.bashrc`: |
| 36 | + |
| 37 | +```bash |
| 38 | +# send alerts to phone via ifttt, or via notify-send if it fails for some reason |
| 39 | +function phone-alert { |
| 40 | + output=$($HOME/code/ifttt-trigger/ifttt-trigger.pl YOUR_LONG_KEY EVENT_NAME "$*"); |
| 41 | + if [ "$?" -ne 0 ]; then |
| 42 | + notify-send -i computer-fail-symbolic "$output (phone alert failed)" |
| 43 | + fi |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +And then use it to make an alert pop up on your phone you when some long running commands finish: |
| 48 | + |
| 49 | +```bash |
| 50 | +$ ant run-really-long-tests; phone-alert "Tests are done" |
| 51 | +``` |
| 52 | + |
| 53 | +Or to send diff messages based on the results: |
| 54 | + |
| 55 | +```bash |
| 56 | +$ ant run-really-long-tests && phone-alert "Tests are done" || phone-alert "Tests failed" |
| 57 | +``` |
| 58 | + |
| 59 | +## Error Handling |
| 60 | + |
| 61 | +If there is an error of any kind: |
| 62 | + |
| 63 | +* Detailed failure information is written to STDERR |
| 64 | +* The input arguments are written to STDOUT |
| 65 | +* A Non-0 exit status is returned. |
| 66 | + |
| 67 | +As shown in the "Suggested Usage" above, this allows you to chain this scipt with other fall back mechanisms for sending alerting you. |
| 68 | + |
| 69 | +## License |
| 70 | + |
| 71 | +Copyright 2016 Chris Hostetter |
| 72 | + |
| 73 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 74 | +you may not use this file except in compliance with the License. |
| 75 | +You may obtain a copy of the License at |
| 76 | + |
| 77 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 78 | + |
| 79 | +Unless required by applicable law or agreed to in writing, software |
| 80 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 81 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 82 | +See the License for the specific language governing permissions and |
| 83 | +limitations under the License. |
0 commit comments