Documentation
¶
Overview ¶
Package idleinhibit is the shared idle-inhibit service: reactive state (active, duration, remaining), the session-bus daemon the `lys-shell idle` CLI drives, and the client half of that interface.
Index ¶
- Constants
- func FormatDuration(totalSecs uint32) string
- type Daemon
- func (d *Daemon) AdjustDuration(deltaMinutes int32) *dbus.Error
- func (d *Daemon) AdjustRemaining(deltaMinutes int32) *dbus.Error
- func (d *Daemon) Disable() *dbus.Error
- func (d *Daemon) Enable(indefinite bool) *dbus.Error
- func (d *Daemon) Export(conn *dbus.Conn) (func(), error)
- func (d *Daemon) Hold(app, reason string, sender dbus.Sender) (uint32, *dbus.Error)
- func (d *Daemon) Release(id uint32, sender dbus.Sender) *dbus.Error
- func (d *Daemon) SetDuration(minutes uint32) *dbus.Error
- func (d *Daemon) SetRemaining(minutes uint32) *dbus.Error
- type Hold
- type Snapshot
- type State
- func (s *State) Active() bool
- func (s *State) AddHold(h Hold) uint32
- func (s *State) AdjustDuration(deltaMinutes int32) error
- func (s *State) AdjustRemaining(deltaMinutes int32)
- func (s *State) Changes() (<-chan struct{}, func())
- func (s *State) Disable()
- func (s *State) Duration() inhibitduration.Duration
- func (s *State) Enable(indefinite bool)
- func (s *State) Holds() map[uint32]Hold
- func (s *State) Indefinite() bool
- func (s *State) Inhibiting() bool
- func (s *State) ReleaseHold(id uint32) bool
- func (s *State) ReleaseOwner(owner string)
- func (s *State) Remaining() uint32
- func (s *State) SetDuration(duration inhibitduration.Duration)
- func (s *State) SetRemaining(minutes uint32)
- func (s *State) Status() Snapshot
Constants ¶
const ( ServiceName = "dev.stubbe.lys.IdleInhibit1" ServicePath = "/dev/stubbe/lys/IdleInhibit" )
D-Bus identity.
const ( ScreenSaverName = "org.freedesktop.ScreenSaver" ScreenSaverPath = dbus.ObjectPath("/org/freedesktop/ScreenSaver") )
The freedesktop ScreenSaver identity Chromium, Electron and media players call to hold idle off: the interface at both paths apps use.
Variables ¶
This section is empty.
Functions ¶
func FormatDuration ¶
FormatDuration renders seconds as H:MM:SS above the hour and M:SS within it.
Types ¶
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the dev.stubbe.lys.IdleInhibit1 object, which the `lys-shell idle` CLI drives from another process and the desktop portal holds idle through for apps.
func (*Daemon) AdjustDuration ¶
AdjustDuration shifts the stored duration, refusing a shift past MaxMinutes with InvalidArgs.
func (*Daemon) AdjustRemaining ¶
AdjustRemaining shifts the time left by minutes.
func (*Daemon) Export ¶
Export serves the interface under its well-known name, and org.freedesktop.ScreenSaver on the same holds unless another program owns that name, and releases the holds of every caller that leaves the bus; the returned release stops all of it.
func (*Daemon) Hold ¶
Hold inhibits idle for app until Release with the returned id, or until the caller leaves the bus.
func (*Daemon) SetDuration ¶
SetDuration stores the duration in minutes, refusing one above MaxMinutes with InvalidArgs.
type Hold ¶
type Hold struct {
Owner, App, Reason string
}
Hold is one app's inhibition: who asked (an owner the daemon releases together when it leaves the bus), for which app, and why.
type Snapshot ¶
type Snapshot struct {
Active bool
Duration inhibitduration.Duration
RemainingS uint32
}
Snapshot is the status view the CLI prints.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is the reactive state: whether the user's inhibition runs, the stored duration in minutes (0 = indefinite), the seconds left on the timer when one is running, and the holds apps (through the desktop portal) keep alongside it.
func NewState ¶
func NewState(duration inhibitduration.Duration) *State
NewState starts with the given duration and inhibition off.
func (*State) AddHold ¶
AddHold registers an app's inhibition, leaving the user's untouched, until the returned id is released.
func (*State) AdjustDuration ¶
AdjustDuration shifts the stored duration: below zero it saturates at zero (indefinite), above MaxMinutes it is refused with ErrDurationRange and the duration stays.
func (*State) AdjustRemaining ¶
AdjustRemaining shifts the seconds left by minutes: a positive delta caps at the stored duration, a negative one saturates at zero, and zero remaining disables the run. Inactive or indefinite runs ignore the call.
func (*State) Changes ¶
func (s *State) Changes() (<-chan struct{}, func())
Changes ticks after every state flip or timer second; every subscriber (the module on each output, the daemon) sees each one. stop ends the feed.
func (*State) Disable ¶
func (s *State) Disable()
Disable turns inhibition off and clears the timer.
func (*State) Duration ¶
func (s *State) Duration() inhibitduration.Duration
Duration returns the stored duration.
func (*State) Enable ¶
Enable turns inhibition on. With indefinite the run has no timer; otherwise the stored duration (if any) counts down and auto-disables.
func (*State) Indefinite ¶
Indefinite reports the indefinite mode: active with no timer.
func (*State) Inhibiting ¶
Inhibiting reports whether idle must be inhibited: the user's inhibition is on, or an app holds one.
func (*State) ReleaseHold ¶
ReleaseHold drops one hold; false when id names none.
func (*State) ReleaseOwner ¶
ReleaseOwner drops every hold owner took.
func (*State) SetDuration ¶
func (s *State) SetDuration(duration inhibitduration.Duration)
SetDuration stores the duration; an active run restarts on it.
func (*State) SetRemaining ¶
SetRemaining replaces the seconds left, capped at the stored duration; zero disables the run. Inactive or indefinite runs ignore the call.