.\" Man page generated from reStructuredText. . .TH "AUTOSUSPEND.CONF" "5" "Jan 22, 2020" "3.0" "autosuspend" .SH NAME autosuspend.conf \- autosuspend config file Documentation . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .sp \fB/etc/autosuspend.conf\fP .SH GENERAL CONFIGURATION .sp Configures the \fBautosuspend\fP daemon. .SS Configuration file .SS Syntax .sp The \fBautosuspend\fP configuration file uses INI syntax and needs to be processable by the Python \fI\%configparser\fP <\fBhttps://docs.python.org/3/library/configparser.html\fP> module. .sp A simple configuration file could look like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [general] interval = 30 idle_time = 900 suspend_cmd = /usr/bin/systemctl suspend wakeup_cmd = echo {timestamp:.0f} > /sys/class/rtc/rtc0/wakealarm notify_cmd_wakeup = su myuser \-c notify\-send \-a autosuspend \(aqSuspending the system. Wake up at {iso}\(aq notify_cmd_no_wakeup = su myuser \-c notify\-send \-a autosuspend \(aqSuspending the system.\(aq lock_file = /var/lock/autosuspend.lock lock_timeout = 30 [check.Ping] enabled = false hosts = 192.168.0.7 [check.RemoteUsers] class = Users enabled = true name = .* terminal = .* host = [0\-9].* [wakeup.File] enabled = True path = /var/run/autosuspend/wakeup .ft P .fi .UNINDENT .UNINDENT .sp The configuration file consists of a \fB[general]\fP section, which specifies general processing options, and multiple sections of the format \fB[check.*]\fP and \fB[wakeup.*]\fP\&. These sections describe the activity and wake up checks to execute. .SS General configuration .sp The \fB[general]\fP section contains options controlling the overall behavior of the \fBautosuspend\fP daemon. These are: .INDENT 0.0 .TP .B interval The time to wait after executing all checks in seconds. .UNINDENT .INDENT 0.0 .TP .B idle_time The required amount of time in seconds with no detected activity before the host will be suspended. Default: 300 seconds .UNINDENT .INDENT 0.0 .TP .B min_sleep_time The minimal amount of time in seconds the system has to sleep for actually triggering suspension. If a scheduled wake up results in an effective time below this value, the system will not sleep. Default: 1200 seconds .UNINDENT .INDENT 0.0 .TP .B wakeup_delta Wake up the system this amount of seconds earlier than the time that was determined for an event that requires the system to be up. This value adds a safety margin for the time a the wake up effectively takes. Default: 30 seconds .UNINDENT .INDENT 0.0 .TP .B 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. .UNINDENT .INDENT 0.0 .TP .B wakeup_cmd The command to execute for scheduling a wake up of the system. The given string is processed using Python\(aqs \fBstr.format()\fP and a format argument called \fBtimestamp\fP encodes the UTC timestamp of the planned wake up time (float). Additionally \fBiso\fP can be used to acquire the timestamp in ISO 8601 format. .UNINDENT .INDENT 0.0 .TP .B notify_cmd_wakeup A command to execute before the system is going to suspend for the purpose of notifying interested clients. This command is only called in case a wake up is scheduled. The given string is processed using Python\(aqs \fBstr.format()\fP and a format argument called \fBtimestamp\fP encodes the UTC timestamp of the planned wake up time (float). Additionally \fBiso\fP can be used to acquire the timestamp in ISO 8601 format. If empty or not specified, no command will be called. .UNINDENT .INDENT 0.0 .TP .B notify_cmd_no_wakeup A command to execute before the system is going to suspend for the purpose of notifying interested clients. This command is only called in case NO wake up is scheduled. Hence, no string formatting options are available. If empty or not specified, no command will be called. .UNINDENT .INDENT 0.0 .TP .B woke_up_file Location of a file that indicates to \fBautosuspend\fP that the computer has suspended since the last time checks were executed. This file is usually created by a \fI\%systemd\fP <\fBhttps://www.freedesktop.org/wiki/Software/systemd/\fP> service. Thus, changing the location also requires adapting the respective service. Refer to systemd\-integration for further details. .UNINDENT .INDENT 0.0 .TP .B lock_file Location of a file that is used to synchronize the continuously running daemon and the systemd callback. .UNINDENT .INDENT 0.0 .TP .B lock_timeout Timeout in seconds used when trying to acquire the lock. This should be longer than the maximum run time of all configured checks. In the worst cases, suspending the system is delayed by this amount of time because \fBpresuspend\fP hook has to wait before all checks have passed. .UNINDENT .SS Activity check configuration .sp For each activity check to execute, a section with the name format \fB[check.*]\fP needs to be created. Each check has a name and an executing class which implements the behavior. The fraction of the section name \fBcheck.\fP determines the name, and in case no class option is given inside the section, also the class which implements the check. In case the \fI\%class\fP option is specified, the name is completely user\-defined and the same check can even be instantiated multiple times with differing names. .sp For each check, these generic options can be specified: .INDENT 0.0 .TP .B class Name of the class implementing the check. If the name does not contain a dot (\fB\&.\fP), this is assumed to be one of the checks provided by autosuspend internally. Otherwise, this can be used to pull in third\-party checks. If this option is not specified, the section name must represent a valid internal check class. .UNINDENT .INDENT 0.0 .TP .B enabled Needs to be \fBtrue\fP for a check to actually execute. \fBfalse\fP is assumed if not specified. .UNINDENT .sp Furthermore, each check might have custom options. .SS Wake up check configuration .sp Wake up checks uses the same configuration logic as the previously described activity checks. However, the configuration file sections start with \fBwakeup.\fP instead of \fBcheck.\fP\&. .sp For options of individual checks, please refer to available\-checks and available\-wakeups\&. .SH AVAILABLE ACTIVITY CHECK .SS Available activity checks .sp The following checks for activity are currently implemented. Each of the is described with its available configuration options and required optional dependencies. .SS ActiveCalendarEvent .sp Checks an online \fI\%iCalendar\fP <\fBhttps://icalendar.readthedocs.io\fP> file for events that are currently running. If so, this indicates activity and prevents suspending the system. Thus, a calendar can be provided with times at which the system should not go to sleep. If this calendar resides on an online service like a groupware it might even be possible to invite the system. .SS Options .INDENT 0.0 .TP .B url The URL to query for the iCalendar file .UNINDENT .INDENT 0.0 .TP .B timeout Timeout for executed requests in seconds. Default: 5. .UNINDENT .INDENT 0.0 .TP .B username Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided. .UNINDENT .INDENT 0.0 .TP .B password Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided. .UNINDENT .SS Requirements .INDENT 0.0 .IP \(bu 2 \fI\%requests\fP <\fBhttps://pypi.python.org/pypi/requests\fP> .IP \(bu 2 \fI\%icalendar\fP <\fBhttps://icalendar.readthedocs.io\fP> .IP \(bu 2 \fI\%dateutil\fP <\fBhttps://dateutil.readthedocs.io\fP> .IP \(bu 2 \fI\%tzlocal\fP <\fBhttps://pypi.org/project/tzlocal/\fP> .UNINDENT .SS ActiveConnection .sp 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. .SS Options .INDENT 0.0 .TP .B ports list of comma\-separated port numbers .UNINDENT .SS Requirements .SS ExternalCommand .sp Executes an arbitrary command. In case this command returns 0, the system is assumed to be active. .sp The command is executed as is using shell execution. Beware of malicious commands in obtained configuration files. .SS Options .INDENT 0.0 .TP .B command The command to execute including all arguments .UNINDENT .SS Requirements .SS Kodi .sp Checks whether an instance of \fI\%Kodi\fP <\fBhttps://kodi.tv/\fP> is currently playing. .SS Options .INDENT 0.0 .TP .B url Base URL of the JSON RPC API of the Kodi instance, default: \fBhttp://localhost:8080/jsonrpc\fP .UNINDENT .INDENT 0.0 .TP .B timeout Request timeout in seconds, default: \fB5\fP .UNINDENT .INDENT 0.0 .TP .B username Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided. .UNINDENT .INDENT 0.0 .TP .B password Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided. .UNINDENT .INDENT 0.0 .TP .B suspend_while_paused Also suspend the system when media playback is paused instead of only suspending when playback is stopped. Default: \fBfalse\fP .UNINDENT .SS Requirements .INDENT 0.0 .IP \(bu 2 \fI\%requests\fP <\fBhttps://pypi.python.org/pypi/requests\fP> .UNINDENT .SS KodiIdleTime .sp Checks whether there has been interaction with the Kodi user interface recently. This prevents suspending the system in case someone is currently browsing collections etc. This check is redundant to \fI\%XIdleTime\fP on systems using an X server, but might be necessary in case Kodi is used standalone. It does not replace the \fI\%Kodi\fP check, as the idle time is not updated when media is playing. .SS Options .INDENT 0.0 .TP .B idle_time Marks the system active in case a user interaction has appeared within the this amount of seconds until now. Default: \fB120\fP .UNINDENT .INDENT 0.0 .TP .B url Base URL of the JSON RPC API of the Kodi instance, default: \fBhttp://localhost:8080/jsonrpc\fP .UNINDENT .INDENT 0.0 .TP .B timeout Request timeout in seconds, default: \fB5\fP .UNINDENT .INDENT 0.0 .TP .B username Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided. .UNINDENT .INDENT 0.0 .TP .B password Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided. .UNINDENT .SS Requirements .INDENT 0.0 .IP \(bu 2 \fI\%requests\fP <\fBhttps://pypi.python.org/pypi/requests\fP> .UNINDENT .SS Load .sp Checks whether the \fI\%system load 5\fP <\fBhttps://en.wikipedia.org/wiki/Load_(computing)\fP> is below a certain value. .SS Options .INDENT 0.0 .TP .B threshold a float for the maximum allowed load value, default: 2.5 .UNINDENT .SS Requirements .SS LogindSessionsIdle .sp Prevents suspending in case \fBIdleHint\fP for one of the running sessions \fI\%logind\fP <\fBhttps://www.freedesktop.org/wiki/Software/systemd/logind/\fP> sessions is set to \fBno\fP\&. Support for setting this hint currently varies greatly across display managers, screen lockers etc. Thus, check exactly whether the hint is set on your system via \fBloginctl show\-session\fP\&. .SS Options .INDENT 0.0 .TP .B types A comma\-separated list of sessions types to inspect for activity. The check ignores sessions of other types. Default: \fBtty\fP, \fBx11\fP, \fBwayland\fP .UNINDENT .INDENT 0.0 .TP .B states A comma\-separated list of session states to inspect. For instance, \fBlingering\fP sessions used for background programs might not be of interest. Default: \fBactive\fP, \fBonline\fP .UNINDENT .SS Requirements .INDENT 0.0 .IP \(bu 2 \fI\%dbus\-python\fP <\fBhttps://cgit.freedesktop.org/dbus/dbus-python/\fP> .UNINDENT .SS Mpd .sp Checks whether an instance of \fI\%MPD\fP <\fBhttp://www.musicpd.org/\fP> is currently playing music. .SS Options .INDENT 0.0 .TP .B host Host containing the MPD daemon, default: \fBlocalhost\fP .UNINDENT .INDENT 0.0 .TP .B port Port to connect to the MPD daemon, default: \fB6600\fP .UNINDENT .INDENT 0.0 .TP .B timeout Request timeout in seconds, default: \fB5\fP .UNINDENT .SS Requirements .INDENT 0.0 .IP \(bu 2 \fI\%python\-mpd2\fP <\fBhttps://pypi.python.org/pypi/python-mpd2\fP> .UNINDENT .SS NetworkBandwidth .sp Checks whether more network bandwidth is currently being used than specified. A set of specified interfaces is checked in this regard, each of the individually, based on the average bandwidth on that interface. This average is based on the global checking interval specified in the configuration file via the \fBinterval\fP option. .SS Options .INDENT 0.0 .TP .B interfaces Comma\-separated list of network interfaces to check .UNINDENT .INDENT 0.0 .TP .B threshold_send If the average sending bandwidth of one of the specified interfaces is above this threshold, then activity is detected. Specified in bytes/s, default: \fB100\fP .UNINDENT .INDENT 0.0 .TP .B threshold_receive If the average receive bandwidth of one of the specified interfaces is above this threshold, then activity is detected. Specified in bytes/s, default: \fB100\fP .UNINDENT .SS Requirements .SS Ping .sp Checks whether one or more hosts answer to ICMP requests. .SS Options .INDENT 0.0 .TP .B hosts Comma\-separated list of host names or IPs. .UNINDENT .SS Requirements .SS Processes .sp 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. .SS Options .INDENT 0.0 .TP .B processes list of comma\-separated process names to check for .UNINDENT .SS Requirements .SS Smb .sp Any active Samba connection will block suspend. .SS Options .INDENT 0.0 .TP .B smbstatus executable needs to be present. .UNINDENT .SS Requirements .SS Users .sp Checks whether a user currently logged in at the system matches several criteria. All provided criteria must match to indicate activity on the host. .SS Options .sp All regular expressions are applied against the full string. Capturing substrings needs to be explicitly enabled using wildcard matching. .INDENT 0.0 .TP .B name A regular expression specifying which users to capture, default: \fB\&.*\fP\&. .UNINDENT .INDENT 0.0 .TP .B terminal A regular expression specifying the terminal on which the user needs to be logged in, default: \fB\&.*\fP\&. .UNINDENT .INDENT 0.0 .TP .B host A regular expression specifying the host from which a user needs to be logged in, default: \fB\&.*\fP\&. .UNINDENT .SS Requirements .SS XIdleTime .sp Checks whether all active local X displays have been idle for a sufficiently long time. Determining which X11 sessions currently exist on a running system is a harder problem than one might expect. Sometimes, the server runs as root, sometimes under the real user, and many other configuration variants exist. Thus, multiple sources for active X serer instances are implemented for this check, each of them having different requirements and limitations. They can be changed using the provided configuration option. .SS Options .INDENT 0.0 .TP .B timeout required idle time in seconds .UNINDENT .INDENT 0.0 .TP .B method The method to use for acquiring running X sessions. Valid options are \fBsockets\fP and \fBlogind\fP\&. The default is \fBsockets\fP\&. .INDENT 7.0 .TP .B \fBsockets\fP Uses the X server sockets files found in \fB/tmp/.X11\-unix\fP\&. This method requires that all X server instances run with user permissions and not as root. .TP .B \fBlogind\fP Uses \fI\%logind\fP <\fBhttps://www.freedesktop.org/wiki/Software/systemd/logind/\fP> to obtain the running X server instances. This does not support manually started servers. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ignore_if_process A regular expression to match against the process names executed by each X session owner. In case the use has a running process that matches this expression, the X idle time is ignored and the check continues as if there was no activity. This can be useful in case of processes which inevitably tinker with the idle time. .UNINDENT .INDENT 0.0 .TP .B ignore_users Do not check sessions of users matching this regular expressions. .UNINDENT .SS Requirements .INDENT 0.0 .IP \(bu 2 \fI\%dbus\-python\fP <\fBhttps://cgit.freedesktop.org/dbus/dbus-python/\fP> for the \fBlogind\fP method .UNINDENT .SS XPath .sp A generic check which queries a configured URL and expects the reply to contain XML data. The returned XML document is checked against a configured \fI\%XPath\fP <\fBhttps://www.w3.org/TR/xpath/\fP> expression and in case the expression matches, the system is assumed to be active. .sp Some common applications and their respective configuration are: .INDENT 0.0 .TP .B \fI\%tvheadend\fP <\fBhttps://tvheadend.org/\fP> The required URL for \fI\%tvheadend\fP <\fBhttps://tvheadend.org/\fP> is (if running on the same host): .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C http://127.0.0.1:9981/status.xml .ft P .fi .UNINDENT .UNINDENT .sp In case you want to prevent suspending in case there are active subscriptions or recordings, use the following XPath: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C /currentload/subscriptions[number(.) > 0] | /currentload/recordings/recording/start .ft P .fi .UNINDENT .UNINDENT .sp If you have a permantently running subscriber like \fI\%Kodi\fP <\fBhttps://kodi.tv/\fP>, increase the \fB0\fP to \fB1\fP\&. .TP .B \fI\%Plex\fP <\fBhttps://www.plex.tv/\fP> For \fI\%Plex\fP <\fBhttps://www.plex.tv/\fP>, use the following URL (if running on the same host): .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C http://127.0.0.1:32400/status/sessions/?X\-Plex\-Token={TOKEN} .ft P .fi .UNINDENT .UNINDENT .sp Where acquiring the token is \fI\%documented here\fP <\fBhttps://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/\fP>\&. .sp If suspending should be prevented in case of any activity, this simple \fI\%XPath\fP <\fBhttps://www.w3.org/TR/xpath/\fP> expression will suffice: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C /MediaContainer[@size > 2] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS Options .INDENT 0.0 .TP .B url The URL to query for the XML reply. .UNINDENT .INDENT 0.0 .TP .B xpath The XPath query to execute. In case it returns a result, the system is assumed to be active. .UNINDENT .INDENT 0.0 .TP .B timeout Timeout for executed requests in seconds. Default: 5. .UNINDENT .INDENT 0.0 .TP .B username Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided. .UNINDENT .INDENT 0.0 .TP .B password Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided. .UNINDENT .SS Requirements .INDENT 0.0 .IP \(bu 2 \fI\%requests\fP <\fBhttps://pypi.python.org/pypi/requests\fP> .IP \(bu 2 \fI\%lxml\fP <\fBhttp://lxml.de/\fP> .UNINDENT .SH AVAILABLE WAKEUP CHECK .SS Available wake up checks .sp The following checks for wake up times are currently implemented. Each of the checks is described with its available configuration options and required optional dependencies. .SS Calendar .sp Determines next wake up time from an \fI\%iCalendar\fP <\fBhttps://icalendar.readthedocs.io\fP> file. The next event that starts after the current time is chosen as the next wake up time. .sp Remember that updates to the calendar can only be reflected in case the system currently running. Changes to the calendar made while the system is sleeping will obviously not trigger an earlier wake up. .SS Options .INDENT 0.0 .TP .B url The URL to query for the XML reply. .UNINDENT .INDENT 0.0 .TP .B username Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided. .UNINDENT .INDENT 0.0 .TP .B password Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided. .UNINDENT .INDENT 0.0 .TP .B xpath The XPath query to execute. Must always return number strings or nothing. .UNINDENT .INDENT 0.0 .TP .B timeout Timeout for executed requests in seconds. Default: 5. .UNINDENT .SS Requirements .INDENT 0.0 .IP \(bu 2 \fI\%requests\fP <\fBhttps://pypi.python.org/pypi/requests\fP> .IP \(bu 2 \fI\%icalendar\fP <\fBhttps://icalendar.readthedocs.io\fP> .IP \(bu 2 \fI\%dateutil\fP <\fBhttps://dateutil.readthedocs.io\fP> .IP \(bu 2 \fI\%tzlocal\fP <\fBhttps://pypi.org/project/tzlocal/\fP> .UNINDENT .SS Command .sp Determines the wake up time by calling an external command The command always has to succeed. If something is printed on stdout by the command, this has to be the next wake up time in UTC seconds. .sp The command is executed as is using shell execution. Beware of malicious commands in obtained configuration files. .SS Options .INDENT 0.0 .TP .B command The command to execute including all arguments .UNINDENT .SS File .sp Determines the wake up time by reading a file from a configured location. The file has to contains the planned wake up time as an int or float in seconds UTC. .SS Options .INDENT 0.0 .TP .B path path of the file to read in case it is present .UNINDENT .SS Periodic .sp Always schedules a wake up at a specified delta from now on. Can be used to let the system wake up every once in a while, for instance, to refresh the calendar used in the \fI\%Calendar\fP check. .SS Options .INDENT 0.0 .TP .B unit A string indicating in which unit the delta is specified. Valid options are: \fBmicroseconds\fP, \fBmilliseconds\fP, \fBseconds\fP, \fBminutes\fP, \fBhours\fP, \fBdays\fP, \fBweeks\fP\&. .UNINDENT .INDENT 0.0 .TP .B value The value of the delta as an int. .UNINDENT .SS XPath .sp A generic check which queries a configured URL and expects the reply to contain XML data. The returned XML document is parsed using a configured \fI\%XPath\fP <\fBhttps://www.w3.org/TR/xpath/\fP> expression that has to return timestamps UTC (as strings, not elements). These are interpreted as the wake up times. In case multiple entries exist, the soonest one is used. .SS Options .INDENT 0.0 .TP .B url The URL to query for the XML reply. .UNINDENT .INDENT 0.0 .TP .B xpath The XPath query to execute. Must always return number strings or nothing. .UNINDENT .INDENT 0.0 .TP .B timeout Timeout for executed requests in seconds. Default: 5. .UNINDENT .INDENT 0.0 .TP .B username Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided. .UNINDENT .INDENT 0.0 .TP .B password Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided. .UNINDENT .SS XPathDelta .sp Comparable to \fI\%XPath\fP, but expects that the returned results represent the wake up time as a delta to the current time in a configurable unit. .sp This check can for instance be used for \fI\%tvheadend\fP <\fBhttps://tvheadend.org/\fP> with the following expression: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C //recording/next/text() .ft P .fi .UNINDENT .UNINDENT .SS Options .INDENT 0.0 .TP .B url The URL to query for the XML reply. .UNINDENT .INDENT 0.0 .TP .B username Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided. .UNINDENT .INDENT 0.0 .TP .B password Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided. .UNINDENT .INDENT 0.0 .TP .B xpath The XPath query to execute. Must always return number strings or nothing. .UNINDENT .INDENT 0.0 .TP .B timeout Timeout for executed requests in seconds. Default: 5. .UNINDENT .INDENT 0.0 .TP .B unit A string indicating in which unit the delta is specified. Valid options are: \fBmicroseconds\fP, \fBmilliseconds\fP, \fBseconds\fP, \fBminutes\fP, \fBhours\fP, \fBdays\fP, \fBweeks\fP\&. Default: minutes .UNINDENT .SH AUTHOR Johannes Wienke .SH COPYRIGHT 2020, Johannes Wienke .\" Generated by docutils manpage writer. .