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 int) 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)
- func (s *State) AdjustRemaining(deltaMinutes int32)
- func (s *State) Changes() (<-chan struct{}, func())
- func (s *State) Disable()
- func (s *State) Duration() uint32
- 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() int
- func (s *State) SetDuration(minutes uint32)
- 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.
Variables ¶
This section is empty.
Functions ¶
func FormatDuration ¶
FormatDuration renders seconds as H:MM:SS above the hour and M:SS within it (helpers.rs's format_duration).
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.
func (*Daemon) AdjustRemaining ¶
AdjustRemaining shifts the time left by minutes.
func (*Daemon) Export ¶
Export serves the interface under its well-known name and releases the holds of every caller that leaves the bus; the returned release stops both.
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.
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 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 (*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; negative clamps at zero.
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) 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 ¶
SetDuration stores the duration in minutes (0 = indefinite); an active run restarts on the new duration.
func (*State) SetRemaining ¶
SetRemaining replaces the seconds left, capped at the stored duration; zero disables the run. Inactive or indefinite runs ignore the call.