diff --git a/sensors.js b/sensors.js index f310161..cfb22f3 100644 --- a/sensors.js +++ b/sensors.js @@ -427,8 +427,11 @@ export const Sensors = GObject.registerClass({ } if ('POWER_NOW' in output) { - this._returnValue(callback, 'Rate', output['POWER_NOW'], 'battery', 'watt'); - this._returnValue(callback, 'battery', output['POWER_NOW'], 'battery-group', 'watt'); + const powerValue = ( + parseFloat(output['POWER_NOW']) * (output['STATUS'] === 'Discharging' ? -1 : 1) + ); + this._returnValue(callback, 'Power Rate', powerValue, 'battery', 'watt'); + this._returnValue(callback, 'battery', powerValue, 'battery-group', 'watt'); } if ('CHARGE_FULL' in output && 'VOLTAGE_MIN_DESIGN' in output && (!('ENERGY_FULL' in output))) { diff --git a/values.js b/values.js index a7cabb0..da83d3f 100644 --- a/values.js +++ b/values.js @@ -186,7 +186,9 @@ export const Values = GObject.registerClass({ ending = 'mAh'; break; case 'watt': - format = (use_higher_precision)?'%.2f %s':'%.1f %s'; + format = ( + ((value > 0) ? '+' : '') + ((use_higher_precision)?'%.2f %s':'%.1f %s') + ); value = value / 1000000; ending = 'W'; break;