coreos/go-systemd

fetching shutdown time in golang

anarcat opened this issue · 1 comments

I'm sorry if this sounds like a "draw the rest of the owl" question, but I'm kind of stuck. I'm trying to fetch the ScheduledShutdown object from D-BUS through this library. I know i can get that property on the command-line with:

$ busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager ScheduledShutdown
(st) "" 18446744073709551615

but trying to find the right entry point in this package seems to beyond my comprehension. It seems the property getters in login1 are restricted to the wrong namespace, and the ones in the dbus namespace are stuck in there own namespace as well...

Is there a way to make a generic request as the above?

thanks

last i dug into this, i found that i should probably talk with the login1/dbus.go library, but the dbus.getProperty method there is not public, so i'm not sure we have what we need to talk with the backend, as the publicly exposed ones don't use the dbusManagerInterface (org.freedesktop.login1.Manager) that we need...

so we'd need to patch this lib to do a public interface something like:

go-systemd/login1/dbus.go

Lines 245 to 257 in 7d375ec

func (c *Conn) GetSession(id string) (dbus.ObjectPath, error) {
var out interface{}
if err := c.object.Call(dbusManagerInterface+".GetSession", 0, id).Store(&out); err != nil {
return "", err
}
ret, ok := out.(dbus.ObjectPath)
if !ok {
return "", fmt.Errorf("failed to typecast session to ObjectPath")
}
return ret, nil
}