Version: v0.0.0-...-5b0139b Latest Latest

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

Go to latest
Published: Jul 27, 2021 License: GPL-3.0 Imports: 4 Imported by: 0




This section is empty.


View Source
var SessionBus = func() (*dbus.Conn, error) {
	if isSessionBusLikelyPresent() {
		return dbus.SessionBus()
	return nil, fmt.Errorf("cannot find session bus")

SessionBus is like dbus.SessionBus but it avoids auto-starting a new dbus-daemon when a bus is not already available.

The go-dbus package will launch a session bus instance on demand when none is present, something we do not want to do. In all contexts where there is a need

to use the session bus, we expect session bus daemon to have been started and

managed by the corresponding user session manager.

This function is mockable by either MockConnections or MockOnlySessionBusAvailable.

View Source
var SystemBus = func() (*dbus.Conn, error) {
	return dbus.SystemBus()

SystemBus is like dbus.SystemBus and is provided for completeness.

This function is mockable by either MockConnections or MockOnlySystemBusAvailable.


func MockConnections

func MockConnections(system, session func() (*dbus.Conn, error)) (restore func())

MockConnections mocks the connection functions system and session buses.

func MockOnlySessionBusAvailable

func MockOnlySessionBusAvailable(conn *dbus.Conn) (restore func())

MockOnlySessionBusAvailable makes SessionBus return the given connection.

In addition calling SystemBus will panic.

func MockOnlySystemBusAvailable

func MockOnlySystemBusAvailable(conn *dbus.Conn) (restore func())

MockOnlySystemBusAvailable makes SystemBus return the given connection.

In addition calling SessionBus will panic.

func SessionBusPrivate

func SessionBusPrivate() (*dbus.Conn, error)

SessionBusPrivate opens a connection to the D-Bus session bus independent of the default shared connection.


This section is empty.

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL