session

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: GPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	sync.Mutex
	PID      int
	Duration time.Duration
	Signals  chan os.Signal
	// contains filtered or unexported fields
}

func New

func New(duration time.Duration, pid int) *Session

Creates a New session instance with duration.

If the session's duration is 0, the session will stop after a termination signal or a call to session.Stop.

func (*Session) Active added in v1.0.7

func (s *Session) Active() bool

A Boolean for session status

func (*Session) Kill

func (s *Session) Kill() error

Kill terminates the current session.

Can be called only when Wait is running in the background.

func (*Session) Start

func (s *Session) Start() error

Starts the session (according to https://people.freedesktop.org/~hadess/idle-inhibition-spec/re01.html) with a call to the D-BUS screensaver inhibitor.

A non-nil error is returned if the D-BUS session connection fails, if the inhabitation call fails or if the cookie recovery fails.

func (*Session) Stop

func (s *Session) Stop() error

Stop kills an already-started session while Wait is not running in the background.

This method is recommended for uses in which the session is required to terminate only by the calling program, and not by the user.

func (*Session) Wait

func (s *Session) Wait(quiet bool) error

Wait can be called only after Start has been called successfully.

Wait will block further execution until the user send an interrupt signal, or until the session duration has passed.

A non-nil error is returned if the un-inhabitation call fails.

Jump to

Keyboard shortcuts

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