IfThenElse is a simple program used to glue small unix tools to getter with the ultimate goal to automate some tedious tasks.
The structure off an IfThenElse chain matches that off a flow chart: Trigger -> Check -> [Then] Action1 | [Else] Action2.
TODO: add nice ascii art picture here.
For example a chain could be:
This should result the light turning off when starting the movie, and on when the movie is finished.
Each IfThenElse chain is an action in itself and can be chained up.
A chain is described in it own file using the KeyFile format. The parser used is the one provided with GLib,
The format used in the KeyFile is very similar to the used on windows, with the following differences:
The above mentioned chain could be described with the following example:
As you can see in the previous example, IfThenElse ties external tools together. A IfThenElse chain can be seen as a flowchart.
Each 'node' in the chain can only have one input and one output connected to each 'port'. So a trigger can only drive one next node, and visa versa.
An example that uses the MultiAction: Say that, in the previous example, we want to turn_off the lights and put gajim in offline mode:
cmd=gajim-remote change_status offline
This way, it is easy to make complex chains.
IfThenElse takes a keyfile describing the chain as input.
To run the program:
ifthenelse <list of input files>
If you want to background IfThenElse.
ifthenelse -b <list of intput files>
If you want to generate a flow chart from the chain:
ifthenelse -d output.dot <list of intput files>
The generated dot file can be converted into an actual chart by running do on it:
dot -Tpng -O output.dotThis will generate a output.dot.png
IfThenElse accepts both individual files as input as directories. If a directory is passed it will, recursively, scan that directory for .ife files.
If no input file is given, it will load the .ife files in the ~/.IfThenElse directory.
IfThenElse accepts the following signals:
Error handling is currently not propperly handled in IfThenElse. In it current form it will exit when any error is encountered.
To disable a script add an empty category called 'disable'. e.g.