On my laptop:
gdbus introspect --system --dest org.freedesktop.UPower --object-path /org/freedesktop/UPower/devices/DisplayDevice
returns a set of properties:
properties:
readonly s NativePath = '';
readonly s Vendor = '';
readonly s Model = '';
readonly s Serial = '';
readonly t UpdateTime = 1669341757;
readonly u Type = 2;
readonly b PowerSupply = true;
readonly b HasHistory = false;
readonly b HasStatistics = false;
readonly b Online = false;
readonly d Energy = 32.719999999999999;
readonly d EnergyEmpty = 0.0;
readonly d EnergyFull = 58.990000000000002;
readonly d EnergyFullDesign = 0.0;
readonly d EnergyRate = 6.2569999999999997;
readonly d Voltage = 0.0;
readonly i ChargeCycles = 0;
readonly d Luminosity = 0.0;
readonly x TimeToEmpty = 18825;
readonly x TimeToFull = 0;
readonly d Percentage = 55.0;
readonly d Temperature = 0.0;
readonly b IsPresent = true;
readonly u State = 2;
readonly b IsRechargeable = false;
readonly d Capacity = 0.0;
readonly u Technology = 0;
readonly u WarningLevel = 1;
readonly u BatteryLevel = 1;
readonly s IconName = 'battery-good-symbolic';
I am trying to modify a gnome shell extension.
when initalising the extension, it does this:
const BUS_NAME = 'org.freedesktop.UPower';
const OBJECT_PATH = '/org/freedesktop/UPower/devices/DisplayDevice';
const DisplayDeviceInterface = loadInterfaceXML('org.freedesktop.UPower.Device'); // see https://upower.freedesktop.org/docs/UPower.html
const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(DisplayDeviceInterface);
...
this._proxy = new PowerManagerProxy(Gio.DBus.system, BUS_NAME, OBJECT_PATH,
...
the existing code accesses a couple of properties like this:
let chargingState = this._proxy.State === UPower.DeviceState.CHARGING
? '-charging' : '';
let fillLevel = 10 * Math.floor(this._proxy.Percentage / 10);
According to the documentation, there is another property EnergyRate (https://upower.freedesktop.org/docs/UPower.html)
and the gdbus call (above) returns a value for many properties, including EnergyRate.
Yet when I do:
global.log("Energy: " + this._proxy.EnergyRate);
the value of the property EnergyRate is undefined. This happens for other defined properties too, such as Energy
Why can't I access all of the properties?