idleinhibit

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 13 Imported by: ? modules, 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.

View Source
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

func FormatDuration(totalSecs uint32) string

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 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, refusing a shift past MaxMinutes with InvalidArgs.

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 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

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, refusing one above MaxMinutes with InvalidArgs.

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
	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) 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) error

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

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() inhibitduration.Duration

Duration returns the stored duration.

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

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

func (*State) SetDuration

func (s *State) SetDuration(duration inhibitduration.Duration)

SetDuration stores the duration; an active run restarts on it.

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