systemsleep

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT 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 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

func Start(who string, prepare func(release func())) *Monitor

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.

func (*Monitor) Close

func (m *Monitor) Close()

Close releases the inhibitor and closes the connection. It does nothing on a nil monitor.

Jump to

Keyboard shortcuts

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