Home - MadWizardDE/Insomnia GitHub Wiki

Central concepts

Insomnia strives to give you a lot more control over when your computer should enter sleep mode and when it should not. It manages this by utilizing dedicated monitors, each watching a different part of the OS and reporting back which resources are currently used in one way or another. The following monitors are part of the core functionality, but can be turned off and on individually:

  • SessionMonitor
  • NetworkMonitor
  • NetworkSessionMonitor
  • ProcessMonitor
  • PowerRequestMonitor

The Timeout

The functionality centers around the idea of a primary timeout, which is a configurable time interval, at which Insomnia asks every installed monitor about the current usage status. This is the delay, after which idle actions are run at the earliest. But most actions can also be configured to be taken after an individual delay since the resource was first discovered to be idle.

Actions and Events

By itself Insomnia doesn't do anything useful or naughty, despite inspecting (and logging) the resource usage every so often. Every action it should take, needs to be configured explicitly in the configuration file (although the installer tries to set it up with sensible defaults). You can recognize configurable actions by the "on"-prefix (most commonly the onIdle and onUsage attributes on the root node of the configuration file). These mark events that can happen in the lifetime of the resource and can be configured with an action to take.

Delaying an action

Most actions and certainly all idle actions can also be configured with a delay, that controls how long the action should be hold back, until it may be allowed to run. The idle event action is a special case here, because that one will reset itself, if the resource detects usage in the meantime. A delay can have the following format:

  • 10s, 5min or 1h for an easily readable notation of a fixed time delay
    • or use 01:05:10 for an ISO 8601 compatible notation
  • 2x for a dynamic multiplier, meaning the event has to be happen so many times in a row, until the action runs eventually (only valid for idle events)

To configure a delay you write a +-sign after the action name and the desired delay value.

Example:

You configured Insomnia with timeout="5min" and an onIdle="sleep+1h". When you leave the computer and no other activity qualifies as proper usage, then after 5 minutes Insomnia will establish the system as being idle. But you would have to wait for another 60 minutes then, until the system really gets suspended. Unless you return during that period and continue to work with the computer. Then it will cancel the pending action and you would now have to wait again for the system to become idle, for anything to happen about the sleep cycle.

There is also a rather passive system event, called onUsage, that basically operates as the antagonist for onIdle. The most sensible action you can configure here would be sleepless, which means to install a built-in power request as long as the system is considered in use, to suppress the automatic sleep management of Windows. You can configure that in order to have a fallback in place, if by happenstance Insomnia stopped working and you left the computer unattended for a longer period of time.