File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -84,17 +84,30 @@ type Conn struct {
8484func New () (* Conn , error ) {
8585 c := new (Conn )
8686
87- if err := c .initConnection (); err != nil {
87+ if err := c .initConnection (dbus . SystemBusPrivate ); err != nil {
8888 return nil , err
8989 }
9090
9191 c .initJobs ()
9292 return c , nil
9393}
9494
95- func (c * Conn ) initConnection () error {
95+ // NewUserConnection() establishes a connection to the session bus and
96+ // authenticates. This can be used to connect to systemd user instances.
97+ func NewUserConnection () (* Conn , error ) {
98+ c := new (Conn )
99+
100+ if err := c .initConnection (dbus .SessionBusPrivate ); err != nil {
101+ return nil , err
102+ }
103+
104+ c .initJobs ()
105+ return c , nil
106+ }
107+
108+ func (c * Conn ) initConnection (createBus func ()(* dbus.Conn , error )) error {
96109 var err error
97- c .sysconn , err = dbus . SystemBusPrivate ()
110+ c .sysconn , err = createBus ()
98111 if err != nil {
99112 return err
100113 }
You can’t perform that action at this time.
0 commit comments