topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 11:00 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: onEVENT  (Read 5823 times)

Sjc1000

  • Member
  • Joined in 2012
  • **
  • Posts: 23
    • View Profile
    • Donate to Member
onEVENT
« on: April 02, 2015, 12:30 AM »
onEVENT is an event system for Linux. Basically it lets you run commands when certain events are True or False. Its fairly flexible, you can pass params to each event.

So far, this is a Linux only project. It might work in Windows i dunno.

Its base is Python and you add events to an event file that is JSON. So if you know JSON and Python you will have fun :)
If not, i have explained how to add your own events to the event file in my github repo ( which i will link to ).

Here are a few examples:

Informs me when i plug in my external hard drive. Also informs me when i unplug it.
{"on": [{"event": "exists", "params": ["/media/steven/TOSHIBA EXT"], "result": "1"}],
"action": [["notify-send","External HDD","External HDD connected! {0}"]],
"repeat": "0",
"delay": {"seconds": "1"},
"alternative": [["notify-send", "External HDD", "External HDD not connected!"]]
}

Informs me when i plug in my Xbox controller.
{"on": [{"event": "inputdevice", "params": ["X-Box 360"], "result": "1"}],
"action": [["notify-send", "Controller", "X-Box device '{0}' connected."]],
"repeat": "0",
"delay": {"seconds": "1"},
"alternative": [["notify-send", "Controller", "X-Box controller disconnected."]]
}


Informs me when i have a new file in my downloads folder. And displays the new file's name.
{"on": [{"event": "newfile", "params": ["/home/steven/Downloads"], "result": 1}],
"action": [["notify-send", "New download!", "New file in the downloads folder! {0}", "-t", "7000"]],
"repeat": "0",
"delay": {"seconds": "5"}
}


Uses the new RSS event to notify me whenever something happens on the Donation Coder forum :D
{"on": [{"event": "rss", "params": ["https://www.donationcoder.com/forum/index.php?action=.xml;type=rss2;limit=10", "DonationCoder"], "result": "1"}],
"action": [["notify-send", "Donation Coder", "[ {boardname} ] {aposter} - {title}"]],
"repeat": "1",
"delay": {"minutes": "5"},
"iterate": "1"
}

These examples are only using the notify-send command on linux. You can run ANY command here, for example, if i plug in my Xbox controller i can run the xbox-drv ( xbox driver ) command automatically.

The link to the repo is here -> https://github.com/Sjc1000/onEVENT

I will keep this updated with stable versions of the main system and event files.
Here is a list of the events -> https://github.com/S...VENT#built-in-events

You can use python eventfile.py  to see the help for that event. Which tells you what params you need to pass.

If you want help with setting up events, or any aspect of this program you can ask :)
If you want instant help, find me on the IRC channel for Donation Coder.  irc.freenode.net:6667  #donationcoder
« Last Edit: April 11, 2015, 08:39 PM by Sjc1000 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: onEVENT
« Reply #1 on: April 02, 2015, 12:57 AM »
Hey that's pretty cool  :up:

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: onEVENT
« Reply #2 on: April 02, 2015, 08:12 AM »
Nice, thanks for sharing!


lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: onEVENT
« Reply #3 on: April 02, 2015, 08:18 AM »
thanks for posting this, Sjc1000! :Thmbsup: