I’m working on a small gnome extension that will perform an action whenever a laptop’s AC adapter is plugged in or unplugged.
To do so in javascript, I’m using a Gio DBusProxy for the org.freedesktop.UPower interface. However, the properties of the proxy are never filled (they are null), and as soon as I call a method on the proxy, I’m getting the following error:
ERROR: DBus: Error org.freedesktop.DBus.Error.ServiceUnknown - The name org.freedesktop.UPower was not provided by any .service files
I can successfully create a proxy for another interface,org.gnome.SettingsDaemon.Power’s Screen, using the same approach. The proxy’s Brightness property then has a valid non-null value that I can access. (That one is on the session bus, while the UPower one is on the system bus, I don’t know whether that matters.) This leads me to believe that the general approach is OK.
I can successfully monitor the AC adapter being unplugged / plugged in from the commandline by running gdbus monitor --system --dest org.freedesktop.UPower --object-path /org/freedesktop/UPower
This is basically what the proxy wrapper code does, just without the automagic property getters/setters. If you’d like help with that, you’ll have to show some code.
OnBattery: null
JS ERROR: Extension example3@example.com: Gio.DBusError: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
_proxyInvoker@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:122:46
_makeProxyMethod/<@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:147:30
disable@/home/chillinr/.local/share/gnome-shell/extensions/example3@example.com/extension.js:251:17
_callExtensionDisable@resource:///org/gnome/shell/ui/extensionSystem.js:109:32
_onEnabledExtensionsChanged/<@resource:///org/gnome/shell/ui/extensionSystem.js:504:45
_onEnabledExtensionsChanged@resource:///org/gnome/shell/ui/extensionSystem.js:504:24