Search code examples
cpusensorsgnometemperaturegnome-shell-extensions

Lm-sensors return wrong result in gnome extension


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?


Solution

  • 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.