SYNOPSYS import "clive/u/user" const Idle = State(iota) ... var IdleIval = 30 * time.Second ... func Becomes() (<-chan State, error) func IdleFor(d time.Duration) <-chan error func IdleTime() (time.Duration, error) func Wakeup() <-chan error type State int DESCRIPTION User events. Currently works only for osx but it should be trivial to fix it to work on other systems as well. CONSTANTS const ( Idle = State(iota) // user is idle for more than IdleIVal seconds Busy // user ceases being idle Awake // user terminal wake up from sleep ) TYPES type State int User states func (i State) String() string FUNCTIONS func Becomes() (<-chan State, error) Notify through the chan returned when the user becomes idle, ceases being idle or resumes after a sleep. Upon errors the channel is closed. func IdleFor(d time.Duration) <-chan error Notify through the chan returned when the user is idle for more than the given duration. If there's any error the chan is notified with the error indication, a null error is sent otherwise. func IdleTime() (time.Duration, error) Return the duration for user idleness, if it's more than one day, one day is reported. func Wakeup() <-chan error Close the returned channel when the terminal resumes from sleep. VARIABLES var ( IdleIval = 30 * time.Second // user is idle if quiet for more than this. PollIval = 5 * time.Second // freq. to poll user for idleness )
Clive, 2nd ed. User's manual. Section 2