I’m trying to call the GetWindows method from the gnome dbus api data/dbus-interfaces/org.gnome.Shell.Introspect.xml · main · GNOME / gnome-shell · GitLab
When I run the code below I get the error: сalling GetWindows()... ** ERROR:main.c:18:test_getwindows: assertion failed (error == NULL): GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: GetWindows is not allowed (g-dbus-error-quark, 9) Bail out! ERROR:main.c:18:test_getwindows: assertion failed (error == NULL): GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: GetWindows is not allowed (g-dbus-error-quark, 9)
AccessDenied led me to think that I needed to run the code via sudo, but this gave another error: Calling GetWindows()... ** ERROR:main.c:18:test_getwindows: assertion failed (error == NULL): GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Shell was not provided by any .service files (g-dbus-error-quark, 2) Bail out! ERROR:main.c:18:test_getwindows: assertion failed (error == NULL): GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Shell was not provided by any .service files (g-dbus-error-quark, 2) Aborted
No, sudo has nothing to do with access control over D-Bus.
The Shell checks for access against an allow-list of D-Bus senders—namely, the XDG desktop portals—or if the shell is in unsafe mode.
You are not allowed to get the list of windows unless you are a privileged component, or you explicitly set the Shell in unsafe mode using Looking Glass.
A system component that is necessary to run the session, like the compositor or the XDG desktop portal implementation.
By being necessary to run the session; you cannot promote any random application, and you definitely cannot do that programmatically, as it would defeat the entire point.
A Shell extension runs inside the compositor, so it is by definition privileged; but it’s also moot, as a shell extension would not use the D-Bus API in the first place, since it has access to the same information as the rest of the compositor.
As I understand it, this is C api, not javascript. And I need to take a screenshot from a gnome extension written in javascript. Or did I understand something wrong? @jadahl
I read the Architecture and Anatomy topics from the link you posted above, but it didn’t answer my questions
Maybe you could tell me what additional topics need to be studied in order to understand how to take a screenshot from the gnome extension, for example @ebassi