logind

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 5 Imported by: 0 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 logind is systemd-logind on the system bus as lys-shell uses it: the user's session resolved without the environment, and logging out of it.

Index

Constants

View Source
const (
	Service     = "org.freedesktop.login1"
	ManagerPath = dbus.ObjectPath("/org/freedesktop/login1")
	ManagerIf   = "org.freedesktop.login1.Manager"
	SessionIf   = "org.freedesktop.login1.Session"
)

The logind service, its manager object, and its interfaces.

View Source
const CallTimeout = 5 * time.Second

CallTimeout is how long one call to logind may take: callers on a path that must not hang give their calls this deadline.

Variables

This section is empty.

Functions

func Logout

func Logout(ctx context.Context, conn *dbus.Conn) error

Logout terminates the user's session: the one Session resolves.

func Session

func Session(ctx context.Context, conn *dbus.Conn) (dbus.ObjectPath, error)

Session resolves the user's session object path through Manager.GetSession("auto"). logind emits signals from the real path, not from the /session/auto alias, so callers keep the resolved one.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the caller's logind session on the system bus.

func NewClient

func NewClient(ctx context.Context, conn *dbus.Conn) (*Client, error)

NewClient resolves the user's session object once (Session) under ctx; every call and signal match uses its real path.

func SystemClient

func SystemClient(ctx context.Context, what string) *Client

SystemClient connects to logind on the system bus under ctx, logging (not failing) when it is unavailable, as what without it is optional; what names the user of the client in the log line. The connection outlives ctx once made.

func (*Client) Listen

func (l *Client) Listen(ctx context.Context, onLock, onUnlock func()) error

Listen delivers the session's Lock and Unlock signals until ctx ends or the bus drops. The callbacks run on the listener goroutine.

func (*Client) LockedHint

func (l *Client) LockedHint(ctx context.Context) (bool, error)

LockedHint reads the session's LockedHint property, waiting no longer than ctx.

func (*Client) Path

func (l *Client) Path() dbus.ObjectPath

Path is the resolved session object path.

func (*Client) SetLockedHint

func (l *Client) SetLockedHint(ctx context.Context, locked bool) error

SetLockedHint tells logind whether the session is locked, waiting no longer than ctx.

Directories

Path Synopsis
Package logindtest is a fake systemd-logind on a private bus, seen from a caller outside any login session: a shell the systemd user manager started.
Package logindtest is a fake systemd-logind on a private bus, seen from a caller outside any login session: a shell the systemd user manager started.

Jump to

Keyboard shortcuts

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