Chapter 5. Creating and Editing Events

The event is the central element of Power Manager. Events can become complex structures as their capabilities are unbounded.

If you are new to Power Manager, we recommend starting with events created using the Assistant. The Assistant helps create the most common individual events, and a selection of useful complete schedules.

Beginning with a selection of Assistant created events is useful. Assistant created events use recommended design patterns and highlight specific features of Power Manager's event capabilities.

Professional's event editor is designed to offer complete control over an event. This control comes at the cost of some complexity. Where possible, we have provided specialised field editors to offer guidance, and reduced the number of required fields needed to perform a given task.

What is an Event?

An event is a structure that encodes a set of triggers, conditions, and actions.

The triggers control when the event is triggered.

The conditions control if a triggered event performs its actions.

The actions control what occurs when the event is performed.

An event may have none, one, or many of each set. That is to say, an event may have multiple triggers, with many conditions, all leading to a sequence of many actions. Alternatively, an event may also have no triggers and conditions, and just one action.

Unique Identifier

Every event has a unique identifier. This identifier is how Power Manager refers to the event. The event's name is used only for presentation. A schedule may have multiple events with the same name, but each event must have a unique identifier.

If Power Manager is provided with two events sharing the same unique identifier, Power Manager will discard the first event of the pair.

Professional's event editor includes a special Create button to suggest a new unique identifier. Professional provides a universally unique identifier; this suggestion will never be repeated again, and no other copy of Professional will ever suggest the same identifier.

Triggers

A trigger controls when an event will be triggered.

The most frequently used triggers represent a specific time and date. The trigger daily and trigger once triggers are likely to be your starting point. Both provide an exact date and time to trigger the event.

Not all triggers revolve around a date and time. Some triggers are linked to user behaviour and actions. The trigger after inactivity trigger is frequently used to replace Mac OS X's sleep after idle time behaviour.

An event's triggers are treated independently. Two triggers within an event do not interact. There is rarely any reason to create a schedule containing two or more events sharing a common set of actions. It is better to create a single event with multiple triggers.

Power Manager will automatically deal with the event as if it were two separate events, each having one of the triggers.

Consider an event with a mix of trigger types. You might want an event to start your back up program. This event could include three triggers: two daily triggers to ensure back ups during the morning and evening, and a third trigger that occurs when the user logs out.

Criteria and Conditions

When a trigger triggers, the event's criteria are consulted. Only if the event's criteria are met will the event's actions be performed.

Criteria allow the creation of events with sophisticated behaviour. Think of triggers as lightweight items. There is little cost to having many triggers, triggering often.

With each trigger, the criteria can make a more thorough inspection of the situation and decide if the actions should be performed.

A trigger daily will trigger once a day, but the event's criteria might limit the actions to performing only between specific dates using a conditional dates condition.

The criteria's conditions might include checking if another program is running, or if the screen is currently being captured for use in a presentation.

An event's criteria are evaluated in order of computational expense. You should not expect every condition to be checked every time. Power Manager does its best to avoid additional overhead.

Actions

If the event has been triggered and the event's criteria have been met, only then are the actions performed.

An event's actions are performed in sequence. The event's first action must be finished, before the second action is begun. This allows complex sequences of actions to be created.

Power Manager is extremely capable. Sequences of actions can span shut downs and restarts. You can perform sequences of scripts separated by unpredictable delays. For example, you could perform the following sequence:

  • running a script;
  • wait for the user to log out;
  • then run another script before restarting;
  • after the restart, wait for the user to log in;
  • finally, perform a third script.
[Note] Power Manager is not a Language

It is tempting to think of Power Manager as a replacement to shell scripting, or other tools such as AppleScript. This view is unlikely to get the best from Power Manager.

Power Manager's design deliberately avoids conditional branches within actions and support for variables.

To get the best from Power Manager, use Power Manager to bring together your preferred external tools. Where possible have Power Manager execute inline shell scripts or call out to other tools. Let Power Manager take control of making sure your Mac is available, and that events are performed precisely when needed.