idleinhibit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 8 Imported by: 1 module, 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 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

View Source
const (
	ServiceName = "dev.stubbe.lys.IdleInhibit1"
	ServicePath = "/dev/stubbe/lys/IdleInhibit"
)

D-Bus identity.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(totalSecs int) string

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 NewDaemon

func NewDaemon(state *State) *Daemon

NewDaemon wraps the state for export.

func (*Daemon) AdjustDuration

func (d *Daemon) AdjustDuration(deltaMinutes int32) *dbus.Error

AdjustDuration shifts the stored duration.

func (*Daemon) AdjustRemaining

func (d *Daemon) AdjustRemaining(deltaMinutes int32) *dbus.Error

AdjustRemaining shifts the time left by minutes.

func (*Daemon) Disable

func (d *Daemon) Disable() *dbus.Error

Disable turns inhibition off.

func (*Daemon) Enable

func (d *Daemon) Enable(indefinite bool) *dbus.Error

Enable turns inhibition on, indefinite or timed.

func (*Daemon) Export

func (d *Daemon) Export(conn *dbus.Conn) (func(), error)

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

func (d *Daemon) Hold(app, reason string, sender dbus.Sender) (uint32, *dbus.Error)

Hold inhibits idle for app until Release with the returned id, or until the caller leaves the bus.

func (*Daemon) Release

func (d *Daemon) Release(id uint32, sender dbus.Sender) *dbus.Error

Release ends a hold the caller took.

func (*Daemon) SetDuration

func (d *Daemon) SetDuration(minutes uint32) *dbus.Error

SetDuration stores the duration in minutes.

func (*Daemon) SetRemaining

func (d *Daemon) SetRemaining(minutes uint32) *dbus.Error

SetRemaining replaces the time left.

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
	DurationMins uint32
	RemainingS   int
}

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(durationMins uint32) *State

NewState starts with the given duration in minutes and inhibition off.

func (*State) Active

func (s *State) Active() bool

Active reports whether inhibition is on.

func (*State) AddHold

func (s *State) AddHold(h Hold) uint32

AddHold registers an app's inhibition, leaving the user's untouched, until the returned id is released.

func (*State) AdjustDuration

func (s *State) AdjustDuration(deltaMinutes int32)

AdjustDuration shifts the stored duration; negative clamps at zero.

func (*State) AdjustRemaining

func (s *State) AdjustRemaining(deltaMinutes int32)

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() uint32

Duration returns the stored duration in minutes, 0 for indefinite.

func (*State) Enable

func (s *State) Enable(indefinite bool)

Enable turns inhibition on. With indefinite the run has no timer; otherwise the stored duration (if any) counts down and auto-disables.

func (*State) Holds

func (s *State) Holds() map[uint32]Hold

Holds lists the apps' holds, by id.

func (*State) Indefinite

func (s *State) Indefinite() bool

Indefinite reports the indefinite mode: active with no timer.

func (*State) Inhibiting

func (s *State) Inhibiting() bool

Inhibiting reports whether idle must be inhibited: the user's inhibition is on, or an app holds one.

func (*State) ReleaseHold

func (s *State) ReleaseHold(id uint32) bool

ReleaseHold drops one hold; false when id names none.

func (*State) ReleaseOwner

func (s *State) ReleaseOwner(owner string)

ReleaseOwner drops every hold owner took.

func (*State) Remaining

func (s *State) Remaining() int

Remaining returns the seconds left, 0 when inactive or indefinite.

func (*State) SetDuration

func (s *State) SetDuration(minutes uint32)

SetDuration stores the duration in minutes (0 = indefinite); an active run restarts on the new duration.

func (*State) SetRemaining

func (s *State) SetRemaining(minutes uint32)

SetRemaining replaces the seconds left, capped at the stored duration; zero disables the run. Inactive or indefinite runs ignore the call.

func (*State) Status

func (s *State) Status() Snapshot

Status reads the current state as a snapshot.

Jump to

Keyboard shortcuts

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