DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: onEVENT  (Read 8,969 times)

Sjc1000

  • Member
  • Joined in 2012
  • **
  • Posts: 23
    • Participated in NANY Challenge Three Times
    • Linux User
onEVENT
« on: April 02, 2015, 05: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.
Code
{"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.
Code
{"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.
Code
{"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
Code
{"on": [{"event": "rss", "params": ["http://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/Sjc1000/onEVENT#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 12, 2015, 01:39 AM by Sjc1000 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: onEVENT
« Reply #1 on: April 02, 2015, 05:57 AM »
Hey that's pretty cool  :up:

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • Cody Award
    • Official Forum Clown
    • rotten turkey sandwich - Rotten Turkey Sandwich
Re: onEVENT
« Reply #2 on: April 02, 2015, 01:12 PM »
Nice, thanks for sharing!

Chris

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: onEVENT
« Reply #3 on: April 02, 2015, 01:18 PM »
thanks for posting this, Sjc1000! :Thmbsup:

Original address: https://www.donationcoder.com/forum/index.php?topic=40569.0