awake

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 New

func New(b Backend) *Keeper

New returns a keeper on b; nil holds nothing.

func (*Keeper) Busy

func (k *Keeper) Busy() int

Busy is how many owners are busy.

func (*Keeper) Close

func (k *Keeper) Close()

Close lets the hold go for good, as the app quits, and waits for it.

func (*Keeper) Held

func (k *Keeper) Held() bool

Held reports whether the system's hold is taken now.

func (*Keeper) Set

func (k *Keeper) Set(owner any, busy bool)

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

func (k *Keeper) SetEnabled(on bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL