Documentation
¶
Overview ¶
Package awake keeps the computer from going to sleep on its own while something needs it up, files transferring: the system's "no idle sleep" hold is taken while at least one owner is busy, and let go once none is. The display may still turn off, and the user can still put the computer to sleep. Each system has its own hold (System); where there is none, or it fails, nothing is held and nothing is said but a log line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// Hold keeps the system from sleeping while idle.
Hold() error
// Release lets it sleep again.
Release() error
}
Backend is a system's hold. Hold and Release are called in turn, never at once, from one goroutine locked to its OS thread (a Windows hold belongs to its thread).
func System ¶
func System() Backend
System is the hold of Linux: a logind inhibitor of idle and sleep, taken by systemd-inhibit for as long as the program it runs, cat reading a pipe of the app's, runs. Closing the pipe ends it, and so does the app ending however it does. Without systemd-inhibit (no systemd) nothing is held.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper takes the hold while any of its owners is busy. It is safe for concurrent use. A nil Keeper, or one without a backend, holds nothing.
func (*Keeper) Close ¶
func (k *Keeper) Close()
Close lets the hold go for good, as the app quits, and waits for it.
func (*Keeper) Set ¶
Set says whether owner is busy. The hold is taken while one is, and let go when the last one is not; saying the same again changes nothing.
func (*Keeper) SetEnabled ¶
SetEnabled turns the keeper on or off (settings.KeepAwake): off, the hold is let go however busy the owners are, and taken again when it is turned back on while one still is.