Documentation
¶
Overview ¶
Package systemsleep lets an app finish work before the system sleeps. It holds a logind sleep delay inhibitor, so that logind waits before a suspend or a hibernation until the app has done its work.
The name keeps the package apart from the sleep timer of pine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor holds a logind sleep delay inhibitor. Before each sleep, it calls prepare, and it releases the inhibitor when prepare calls release or when the wait time ends. After the wake, it takes a new inhibitor.
func Start ¶
Start connects to the system bus and starts a monitor. who is the name that logind shows for the inhibitor. prepare runs in its own goroutine before each sleep, and it must call release when its work has ended.
Without a system bus, for example on macOS and Windows, Start logs the cause and returns nil. A nil monitor is valid.