package main import ( "fmt" "os" keychainlinker "git.aetherial.dev/aeth/keychain-linker/pkg" "github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5/introspect" ) const ( dbusName = "org.freedesktop.secrets" objPath = "/org/freedesktop/secrets/collection/default" iface = "org.freedesktop.Secret.Collection" ) func main() { conn, err := dbus.ConnectSessionBus() if err != nil { panic(err) } defer conn.Close() path := "/org/freedesktop/secrets" service := keychainlinker.NewService(dbus.ObjectPath(path)) conn.Export(service, dbus.ObjectPath(path), "org.freedesktop.Secret.Service") conn.Export(introspect.Introspectable(keychainlinker.DbusAdv), dbus.ObjectPath(path), "org.freedesktop.DBus.Introspectable") /* node := introspect.Node{ Interfaces: []introspect.Interface{ { Name: "org.freedesktop.Secret.Service", Methods: []introspect.Method{ {Name: "Get", Args: []introspect.Arg{{Name: "interface_name", Type: "s", Direction: "in"}, {Name: "property_name", Type: "s", Direction: "in"}, {Name: "value", Type: "v", Direction: "out"}}}, {Name: "Set", Args: []introspect.Arg{{Name: "interface_name", Type: "s", Direction: "in"}, {Name: "property_name", Type: "s", Direction: "in"}, {Name: "value", Type: "v", Direction: "in"}}}, {Name: "GetAll", Args: []introspect.Arg{{Name: "interface_name", Type: "s", Direction: "in"}, {Name: "props", Type: "a{sv}", Direction: "out"}}}, }, }, }, } */ conn.Export(introspect.NewIntrospectable(&keychainlinker.ServiceNode), dbus.ObjectPath(path), "org.freedesktop.DBus.Introspectable") collection := &keychainlinker.Collection{} conn.Export(collection, objPath, iface) /* collectionNode := introspect.Node{ Interfaces: []introspect.Interface{ { Name: iface, Methods: []introspect.Method{ {Name: "Get", Args: []introspect.Arg{{Name: "interface_name", Type: "s", Direction: "in"}, {Name: "property_name", Type: "s", Direction: "in"}, {Name: "value", Type: "v", Direction: "out"}}}, {Name: "Set", Args: []introspect.Arg{{Name: "interface_name", Type: "s", Direction: "in"}, {Name: "property_name", Type: "s", Direction: "in"}, {Name: "value", Type: "v", Direction: "in"}}}, { Name: "SearchItems", Args: []introspect.Arg{ {Name: "attributes", Type: "a{ss}", Direction: "in"}, {Name: "locked", Type: "ao", Direction: "out"}, {Name: "unlocked", Type: "ao", Direction: "out"}, }, }, }, }, }, } */ conn.Export(introspect.NewIntrospectable(&keychainlinker.CollectionNode), dbus.ObjectPath(path+"/collection/default"), "org.freedesktop.DBus.Introspectable") reply, err := conn.RequestName(dbusName, dbus.NameFlagDoNotQueue) if err != nil { panic(err) } if reply != dbus.RequestNameReplyPrimaryOwner { fmt.Fprintln(os.Stderr, "name already taken") os.Exit(1) } fmt.Println("Listening on org.freedesktop.secrets / /org/freedesktop/secrets ...") select {} }