-1

I am writing a simple gnome extension to control my CPU temperature but i have a rare problem. When i execute sensors in shell i have this result:

dell_smm-virtual-0
Adapter: Virtual device
Processor Fan:    0 RPM
CPU:            +53.0°C
Other:          +46.0°C
Other:          +52.0°C
GPU:            +16.0°C

acpitz-virtual-0
Adapter: Virtual device
temp1:        +53.5°C  (crit = +99.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +57.0°C  (high = +86.0°C, crit = +100.0°C)
Core 0:         +57.0°C  (high = +86.0°C, crit = +100.0°C)
Core 1:         +55.0°C  (high = +86.0°C, crit = +100.0°C)

and when i execute the same command with GLib.spawn_command_line_sync('sensors') i get 10 or more degrees more for my CPU temperature:

JS LOG: ----------->, dell_smm-virtual-0
Adapter: Virtual device
Processor Fan:    0 RPM
CPU:            +67.0°C  
Other:          +46.0°C  
Other:          +52.0°C  
GPU:            +16.0°C  

acpitz-virtual-0
Adapter: Virtual device
temp1:        +67.5°C  (crit = +99.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +68.0°C  (high = +86.0°C, crit = +100.0°C)
Core 0:         +65.0°C  (high = +86.0°C, crit = +100.0°C)
Core 1:         +68.0°C  (high = +86.0°C, crit = +100.0°C)

whats wrong?

Toni Chaz
  • 651
  • 11
  • 22

1 Answers1

0

Perhaps it's the use of spawn_command_line_sync() causing your CPU to momentarily ramp up? I would try an async call, just to check.

Incidentally, see util.js which has a function spawnCommandLine() that runs the command asynchronously and automatically handles errors. The import is imports.misc.util;.

And if using an async call fixes your high CPU problem, I'd be interested to hear about it.

andy.holmes
  • 3,383
  • 17
  • 28
  • Hi @andy.holmes finally i solved with the main.loop. When i print the temperature every two seconds, i get the correct temperatures. It´s rare but works. Only fails the first time. – Toni Chaz Jun 28 '17 at 09:24
  • Interesting, thanks for letting me know it's not a `spawn_sync` issue. – andy.holmes Jun 28 '17 at 20:00