@@ -455,15 +455,15 @@ export const Sensors = GObject.registerClass({
455455 this . _returnValue ( callback , 'Energy (now)' , output [ 'ENERGY_NOW' ] , 'battery' , 'watt-hour' ) ;
456456 }
457457
458- if ( 'ENERGY_FULL' in output && 'ENERGY_NOW' in output && 'POWER_NOW' in output && output [ 'POWER_NOW' ] > 0 && 'STATUS' in output && ( output [ 'STATUS' ] == 'Charging' || output [ 'STATUS' ] == 'Discharging' ) ) {
458+ if ( 'ENERGY_FULL' in output && 'ENERGY_NOW' in output && 'POWER_NOW' in output && output [ 'POWER_NOW' ] !== 0 && 'STATUS' in output && ( output [ 'STATUS' ] == 'Charging' || output [ 'STATUS' ] == 'Discharging' ) ) {
459459
460460 let timeLeft = 0 ;
461461
462462 // two different formulas depending on if we are charging or discharging
463463 if ( output [ 'STATUS' ] == 'Charging' ) {
464464 timeLeft = ( ( output [ 'ENERGY_FULL' ] - output [ 'ENERGY_NOW' ] ) / output [ 'POWER_NOW' ] ) ;
465465 } else {
466- timeLeft = ( output [ 'ENERGY_NOW' ] / output [ 'POWER_NOW' ] ) ;
466+ timeLeft = ( output [ 'ENERGY_NOW' ] / Math . abs ( output [ 'POWER_NOW' ] ) ) ;
467467 }
468468
469469 // don't process Infinity values
@@ -644,7 +644,7 @@ export const Sensors = GObject.registerClass({
644644 if ( vendor === "0x1002" ) {
645645 // read GPU usage and create group lebel for card
646646 new FileModule . File ( '/sys/class/drm/card' + i + '/device/gpu_busy_percent' ) . read ( ) . then ( value => {
647- // create group
647+ // create group
648648 this . _returnGpuValue ( callback , 'Graphics' , parseInt ( value ) * 0.01 , typeName + '-group' , 'percent' ) ;
649649 this . _returnGpuValue ( callback , 'Vendor' , "AMD" , typeName , 'string' ) ;
650650 this . _returnGpuValue ( callback , 'Usage' , parseInt ( value ) * 0.01 , typeName , 'percent' ) ;
0 commit comments