Giter Site home page Giter Site logo

davedavenport / ifthenelse Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 2.0 283 KB

A small if then else utility.

Home Page: http://api.sarine.nl/ifthenelse/ifthenelse/IfThenElse.html

License: GNU General Public License v2.0

Vala 95.84% Shell 0.45% Makefile 1.40% Python 1.83% M4 0.48%

ifthenelse's Introduction

Description:

IfThenElse is a simple program used to glue small unix tools together with the ultimate goal to automate some tedious tasks.

The structure off an IfThenElse chain is as follow: Trigger -> Check -> [Then] Action1 | [Else] Action2

For example a chain could be:

Trigger: Every minute
Check: Is a Movie Playing
Then: Turn off the light
Else: Turn on the light

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.

File format

A chain is described in it own file using the ini format. The above example would look like:

[Trigger]
type=TimerTrigger
timeout=60
action=Check

[Check]
type=ExternalToolCheck
cmd=check_movies.sh
true_status=1
false_status=0
compare_old_state=true
then_action=Then
else_action=Else

[Then]
type=ExternalToolAction
cmd=switch_off_lights.sh

[Else]
type=ExternalToolAction
cmd=switch_on_lights.sh

As you can see all it does is to tie external tools together. If you want to use multiple triggers, or drive multiple actions you have to use the MultiCombine node in between to combine the different inputs, or the MultiAction to drive multiple actions.

So say that we want to turn_off the lights and put gajim in offline mode:

[Trigger]
type=TimerTrigger
timeout=60
action=Check

[Check]
type=ExternalToolCheck
cmd=check_movies.sh
true_status=1
false_status=0
compare_old_state=true
then_action=ThenMulti
else_action=Else

[ThenMulti]
type=MultiAction
action=Then1;Then2

[Then1]
type=ExternalToolAction
cmd=switch_off_lights.sh

[Then2]
type=ExternalToolAction
cmd=gajim-remote change_status offline

[Else]
type=ExternalToolAction
cmd=switch_on_lights.sh

This way, it is easy to make complex chains.

Using the program

Run the program:

ifthenelse <list of input files>

If you want to generate a dot graph:

ifthenelse -d output.dot <list of intput files>

If you want to background IfThenElse.

ifthenelse -b <list of intput files>

If a directory is passed it will, recursively, scan that directory for .ife files.

To stop the program send it a TERM/HUP/INT signal (e.g. press ctrl-c)

To force it to reload the input files send it a USR1 signal.

ifthenelse's People

Contributors

davedavenport avatar martijnktue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ifthenelse's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.