package login1

import "github.com/coreos/go-systemd/v22/login1"

Package login1 provides integration with the systemd logind API. See http://www.freedesktop.org/wiki/Software/systemd/logind/

Index

Types

type Conn

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

Conn is a connection to systemds dbus endpoint.

func New

func New() (*Conn, error)

New establishes a connection to the system bus and authenticates.

func (*Conn) Close

func (c *Conn) Close()

Close closes the dbus connection

func (*Conn) Connected

func (c *Conn) Connected() bool

Connected returns whether conn is connected

func (*Conn) GetActiveSession

func (c *Conn) GetActiveSession() (dbus.ObjectPath, error)

GetActiveSession may be used to get the session object path for the current active session

func (*Conn) GetSession

func (c *Conn) GetSession(id string) (dbus.ObjectPath, error)

GetSession may be used to get the session object path for the session with the specified ID.

func (*Conn) GetSessionDisplay

func (c *Conn) GetSessionDisplay(sessionPath dbus.ObjectPath) (string, error)

GetSessionDisplay may be used to get the display for specific session

func (*Conn) GetSessionPropertiesContext

func (c *Conn) GetSessionPropertiesContext(ctx context.Context, sessionPath dbus.ObjectPath) (map[string]dbus.Variant, error)

GetSessionPropertiesContext takes a session path and returns all of its dbus object properties.

func (*Conn) GetSessionPropertyContext

func (c *Conn) GetSessionPropertyContext(ctx context.Context, sessionPath dbus.ObjectPath, property string) (*dbus.Variant, error)

GetSessionPropertyContext takes a session path and a property name and returns the property value.

func (*Conn) GetSessionUser

func (c *Conn) GetSessionUser(sessionPath dbus.ObjectPath) (*User, error)

GetSessionUser may be used to get the user of specific session

func (*Conn) GetUserPropertiesContext

func (c *Conn) GetUserPropertiesContext(ctx context.Context, userPath dbus.ObjectPath) (map[string]dbus.Variant, error)

GetUserPropertiesContext takes a user path and returns all of its dbus object properties.

func (*Conn) GetUserPropertyContext

func (c *Conn) GetUserPropertyContext(ctx context.Context, userPath dbus.ObjectPath, property string) (*dbus.Variant, error)

GetUserPropertyContext takes a user path and a property name and returns the property value.

func (*Conn) Inhibit

func (c *Conn) Inhibit(what, who, why, mode string) (*os.File, error)

Inhibit takes inhibition lock in logind.

func (*Conn) ListSessions

func (c *Conn) ListSessions() ([]Session, error)

Deprecated: use ListSessionsContext instead.

func (*Conn) ListSessionsContext

func (c *Conn) ListSessionsContext(ctx context.Context) ([]Session, error)

ListSessionsContext returns an array with all current sessions.

func (*Conn) ListUsers

func (c *Conn) ListUsers() ([]User, error)

Deprecated: use ListUsersContext instead.

func (*Conn) ListUsersContext

func (c *Conn) ListUsersContext(ctx context.Context) ([]User, error)

ListUsersContext returns an array with all currently logged-in users.

func (*Conn) LockSession

func (c *Conn) LockSession(id string)

LockSession asks the session with the specified ID to activate the screen lock.

func (*Conn) LockSessions

func (c *Conn) LockSessions()

LockSessions asks all sessions to activate the screen locks. This may be used to lock any access to the machine in one action.

func (*Conn) PowerOff

func (c *Conn) PowerOff(askForAuth bool)

PowerOff asks logind for a power off optionally asking for auth.

func (*Conn) Reboot

func (c *Conn) Reboot(askForAuth bool)

Reboot asks logind for a reboot optionally asking for auth.

func (*Conn) Subscribe

func (c *Conn) Subscribe(members ...string) chan *dbus.Signal

Subscribe to signals on the logind dbus

func (*Conn) TerminateSession

func (c *Conn) TerminateSession(id string)

TerminateSession forcibly terminate one specific session.

func (*Conn) TerminateUser

func (c *Conn) TerminateUser(uid uint32)

TerminateUser forcibly terminates all processes of a user.

type Session

type Session struct {
	ID   string
	UID  uint32
	User string
	Seat string
	Path dbus.ObjectPath
}

Session object definition.

type User

type User struct {
	UID  uint32
	Name string
	Path dbus.ObjectPath
}

User object definition.

Source Files

dbus.go

Version
v22.5.0 (latest)
Published
Nov 7, 2022
Platform
linux/amd64
Imports
6 packages
Last checked
1 year ago

Tools for package owners.