Trigger an event or notification upon the output of a command
Project description
About
=====
triggerd is a Python script that is used to trigger an event or notification upon the output of a command
An event file containing the trigger criteria is created. Ideally, you'll create an entry in cron to execute ``triggerd EVENTFOLDER`` on a regular basis. If the command status or output matches the trigger criteria, a trigger event or notification is executed and the event file is marked triggered.
triggerd is perfect for querying a webpage for matching text or anything of the sort. I originally created it for use with a modified version of urlwatch to notify me upon certain changes to webpages, however the potential uses are limitless.
The script was originally written in Bash shell script. It is nearly syntactically identical to the Python version and is a great alternative if Python 3 is not available in your environment. It is included in this repository under ``scripts/triggerd.sh``. It is placed in your local bin folder upon installation of triggerd via pip.
Installation
============
The easiest way to install triggerd is via pip (assuming it is installed).
::
pip3 install --user triggerd
FYI: The shell version of triggerd will be included in your local bin folder as ``triggerd.sh``
Update
=======
Run the following command to update to the most recent version:
::
pip3 install --upgrade --user triggerd
Usage
===========
triggerd is controlled via configuration files called event files. You can execute it as follows:
::
triggerd FILE1 FILE2 FILE3...
Or against entire directories of event files:
::
triggerd EVENTFOLDER1 EVENTFOLDER2...
You can test your event file configuration without actually executing it:
::
triggerd --verify FILE
The --verbose option can be used to display execution details:
::
triggerd --verbose FILE
Event Files
===========
Here is a sample event file:
::
COMMAND=curl -s google.com | grep -q google
EVENT_NAME=Google
MATCH_CONTENT=0
MATCH_CRITERIA=eq
STATUS=enabled
TEST_TYPE=status
TRIGGER_CUSTOM=notify-send "Google is alive!"
**TEST_TYPE** options:
::
arithmetic
content
status (exit code)
**MATCH_CRITERIA** for arithmetic and status tests:
::
eq
ge
gt
le
lt
ne
**MATCH_CRITERIA** for content tests:
::
contains
does_not_contain
matches
does_not_match
null
not_null
**STATUS** indicates whether the event is active:
::
enabled
disabled
triggered (this will be set by triggerd upon a trigger event)
Triggers
========
There are two types of triggers available.
``TRIGGER_CUSTOM`` is used to indicate a shell command.
i.e. ``TRIGGER_CUSTOM=notify-send "Trigger Notification"
``TRIGGER_NAMED`` is used to indicate a trigger template.
The trigger templates may be defined in ``$HOME/.config/scripts/triggerd/triggers.conf``
ie. ``special=notify-send --icon=~/.config/scripts/triggerd/icons/special.png --urgency=critical "triggerd: $EVENT_NAME" "special event was triggered!"``
The event name can be used in either trigger as ``$EVENT_NAME``.
If no trigger is indicated, a default notification will be displayed via notify-send.
License
=======
Copyright (c) 2015 Six (brbsix@gmail.com).
Licensed under the GPLv3 license.
=====
triggerd is a Python script that is used to trigger an event or notification upon the output of a command
An event file containing the trigger criteria is created. Ideally, you'll create an entry in cron to execute ``triggerd EVENTFOLDER`` on a regular basis. If the command status or output matches the trigger criteria, a trigger event or notification is executed and the event file is marked triggered.
triggerd is perfect for querying a webpage for matching text or anything of the sort. I originally created it for use with a modified version of urlwatch to notify me upon certain changes to webpages, however the potential uses are limitless.
The script was originally written in Bash shell script. It is nearly syntactically identical to the Python version and is a great alternative if Python 3 is not available in your environment. It is included in this repository under ``scripts/triggerd.sh``. It is placed in your local bin folder upon installation of triggerd via pip.
Installation
============
The easiest way to install triggerd is via pip (assuming it is installed).
::
pip3 install --user triggerd
FYI: The shell version of triggerd will be included in your local bin folder as ``triggerd.sh``
Update
=======
Run the following command to update to the most recent version:
::
pip3 install --upgrade --user triggerd
Usage
===========
triggerd is controlled via configuration files called event files. You can execute it as follows:
::
triggerd FILE1 FILE2 FILE3...
Or against entire directories of event files:
::
triggerd EVENTFOLDER1 EVENTFOLDER2...
You can test your event file configuration without actually executing it:
::
triggerd --verify FILE
The --verbose option can be used to display execution details:
::
triggerd --verbose FILE
Event Files
===========
Here is a sample event file:
::
COMMAND=curl -s google.com | grep -q google
EVENT_NAME=Google
MATCH_CONTENT=0
MATCH_CRITERIA=eq
STATUS=enabled
TEST_TYPE=status
TRIGGER_CUSTOM=notify-send "Google is alive!"
**TEST_TYPE** options:
::
arithmetic
content
status (exit code)
**MATCH_CRITERIA** for arithmetic and status tests:
::
eq
ge
gt
le
lt
ne
**MATCH_CRITERIA** for content tests:
::
contains
does_not_contain
matches
does_not_match
null
not_null
**STATUS** indicates whether the event is active:
::
enabled
disabled
triggered (this will be set by triggerd upon a trigger event)
Triggers
========
There are two types of triggers available.
``TRIGGER_CUSTOM`` is used to indicate a shell command.
i.e. ``TRIGGER_CUSTOM=notify-send "Trigger Notification"
``TRIGGER_NAMED`` is used to indicate a trigger template.
The trigger templates may be defined in ``$HOME/.config/scripts/triggerd/triggers.conf``
ie. ``special=notify-send --icon=~/.config/scripts/triggerd/icons/special.png --urgency=critical "triggerd: $EVENT_NAME" "special event was triggered!"``
The event name can be used in either trigger as ``$EVENT_NAME``.
If no trigger is indicated, a default notification will be displayed via notify-send.
License
=======
Copyright (c) 2015 Six (brbsix@gmail.com).
Licensed under the GPLv3 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
triggerd-0.2.tar.gz
(12.1 kB
view hashes)
Built Distribution
triggerd-0.2-py3-none-any.whl
(15.2 kB
view hashes)