coreos / go-systemd

Go bindings to systemd socket activation, journal, D-Bus, and unit files
Apache License 2.0
2.43k stars 306 forks source link

fetching shutdown time in golang #447

Open anarcat opened 1 month ago

anarcat commented 1 month ago

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

anarcat commented 1 month ago

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:

https://github.com/coreos/go-systemd/blob/7d375ecc2b092916968b5601f74cca28a8de45dd/login1/dbus.go#L245-L257