autosuspend.conf

Synopsis

/etc/autosuspend.conf

Description

Configures the autosuspend daemon.

Syntax

The autosuspend configuration file uses INI syntax and needs to be processable by the Python configparser module.

A simple configuration file could look like:

[general]
interval = 30
idle_time = 900
suspend_cmd = /usr/bin/systemctl suspend

[check.Ping]
enabled = false
hosts = 192.168.0.7

[check.RemoteUsers]
class = Users
enabled = true
name = .*
terminal = .*
host = [0-9].*

The configuration file consists of a [general] section, which specifies general processing options, and multiple options of the format [check.*]. These sections describe the checks to execute to determine inactivity.

General Configuration

The [general] section contains options controlling the overall behavior of the autosuspend daemon. These are:

interval

The time to wait after executing all checks in seconds.

idle_time

The required amount of time in seconds with no detected activity before the host will be suspended.

suspend_cmd

The command to execute in case the host shall be suspended. This line can contain additional command line arguments to the command to execute.

Check Configuration

For each check to execute, a section with the name format [check.*] needs to be created. Each check has a name and an executing class which implements the behavior. The fraction of the section name check. determines the name, and in case no class option is given inside the section, also the class which implements the check. In case the option:`class option is specified, the name is completely user-defined and the same check can even be instantiated multiple times with differing names.

For each check, these generic options can be specified:

class

Name of the class implementing the check. If this is not specified, the section name must represent a valid check class (see list below).

enabled

Needs to be true for a check to actually execute. false is assumed if not specified.

Furthermore, each check might have custom options.

Available checks

The following checks for activity are currently implemented. Each of the is described with its available configuration options and required optional dependencies.

Ping

Checks whether one or more hosts answer to ICMP requests.

Options

hosts

Comma-separated list of host names or IPs.

Requirements

Mpd

Checks whether an instance of MPD is currently playing music.

Options

host

Host containing the MPD daemon, default: localhost

port

Port to connect to the MPD daemon, default: 6600

timeout

Request timeout in seconds, default: 5

Requirements

Kodi

Checks whether an instance of Kodi is currently playing.

Options

url

Base URL of the JSON RPC API of the Kodi instance, default: http://localhost:8080/jsonrpc

timeout

Request timeout in seconds, default: 5

Requirements

Users

Checks whether a user currently logged in at the system matches several criteria. All provided criteria must match to indicate activity on the host.

Options

All regular expressions are applied against the full string. Capturing substrings needs to be explicitly enabled using wildcard matching.

name

A regular expression specifying which users to capture, default: .*.

terminal

A regular expression specifying the terminal on which the user needs to be logged in, default: .*.

host

A regular expression specifying the host from which a user needs to be logged in, default: .*.

Requirements

Smb

Any active Samba connection will block suspend.

Options

Requirements

smbstatus

executable needs to be present.

Processes

If currently running processes match an expression, the suspend will be blocked. You might use this to hinder the system from suspending when for example your rsync runs.

Options

processes

list of comma-separated process names to check for

Requirements

ActiveConnection

Checks whether there is currently a client connected to a TCP server at certain ports. Can be used to e.g. block suspending the system in case SSH users are connected or a web server is used by clients.

Options

ports

list of comma-separated port numbers

Requirements

Load

Checks whether the system load 5 is below a certain value.

Options

threshold

a float for the maximum allowed load value, default: 2.5

Requirements

XIdleTime

Checks whether all active local X displays have been idle for a sufficiently long time. This assumes a recent operating system where the X server is started with user permissions (i.e. not as root).

Options

timeout

required idle time in seconds

ignore_if_process

a regular expression to match against the process names executed by each X session owner. In case the use has a process running, which matches against this expression, the X idle time is ignore and the check continues as if there was no activity. This can be useful in case of processes which inevitabl

The options of individual checks are outlined below.