Is there a way to automatically run scripts based on conditions on PC/Mac/Linux, like Tasker for Android?

5

2

I'm not thinking about pure scheduled tasks, but rather things where a daemon in the background will automatically trigger a script when certain conditions are met.

For those who have used Tasker on Android, you probably have an idea of what I'm talking about already. For those who don't, this would include things like:

  • automatically triggering scripts when a Macbook is plugged in or unplugged; or
  • having the computer automatically go into sleep mode when it gets a certain message (via an open port, or email, or whatever), and similarly wake up again; or
  • automatically opening a connection to a file server on the same network at a certain time of day; and so on.

I've seen assorted software tools to do this kind of thing piecemeal, but I'd be extremely curious in finding any mostly-integrated way, premade or homebrew, to accomplish the same kind of flexibility in automation that I've gotten used to on my phone.

I also figure this question will be most helpful if applied across the range of OSes rather than more limited.

Roadie

Posted 2011-10-30T03:53:20.377

Reputation: 59

2Please explain what you expect in an accepted answer. Do you need the same person to know the internals of all major operating systems? How much scripting, configuration, and file editing are you willing to do to accomplish this? What kinds of operations do you want to trigger using what criteria? – Daniel Beck – 2011-10-30T12:32:03.520

Answers

4

I'm not thinking about pure scheduled tasks

Actually, I think you are thinking of Scheduled Tasks, as least in Windows. In Windows 7, you can set up scheduled tasks that start based on certain events. I know at least 1 and 3 from your list, and possibly also #2 depending on the app that's listening.


The screen shot below shows the available trigger options. The big one here is the "On an event" option, as Windows writes a huge amount of information to the event log. It's just a matter of tracking an example down in the event viewer.

Task Trigger

An example for "Resume from sleep", choose the System event log, the Power-Troubleshooter source, and Event ID 1. The "custom" option allows you to also filter on the data in the event.

Joel Coehoorn

Posted 2011-10-30T03:53:20.377

Reputation: 26 787

Huh! I wasn't aware of that one, having not used 7 much myself. Is there a list anywhere of the triggers that it can use? – Roadie – 2011-10-30T04:12:33.113

@Roadie - updated my answer. – Joel Coehoorn – 2011-10-30T04:16:30.003

0

A Mac solution that I discovered myself recently is ControlPlane.

A very useful application developed as a fork of the MarcoPolo project. MarcoPolo brings context-aware computing to your portable Mac computer.

It allows your computer to determine its context through gathering evidence from your environment (evidence sources), using flexible rule-based fuzzy matching to make an educated guess (rules), and then performing arbitrary actions upon changing context (actions).

The concept of contexts is a generalisation of a location, and encompasses more than just where your computer is. A context might represent what you are doing, or what else is going on around you.

It quietly stays in the status bar at the top of your screen (right-hand side of the menu bar), from where it can be configured to your own needs.

Roadie

Posted 2011-10-30T03:53:20.377

Reputation: 1