Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetching shutdown time in golang #447

Open
anarcat opened this issue Sep 4, 2024 · 1 comment
Open

fetching shutdown time in golang #447

anarcat opened this issue Sep 4, 2024 · 1 comment

Comments

@anarcat
Copy link

anarcat commented Sep 4, 2024

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
Copy link
Author

anarcat commented Sep 5, 2024

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant