Lm-sensors return 导致 gnome 扩展错误

Lm-sensors return wrong result in gnome extension

我正在编写一个简单的 gnome 扩展来控制我的 CPU 温度,但我遇到了一个罕见的问题。当我在 shell 中执行 sensors 时,我得到了这个结果:

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)

当我使用 GLib.spawn_command_line_sync('sensors') 执行相同的命令时,我的 CPU 温度升高了 10 度或更多度:

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)

怎么了?

也许是使用 spawn_command_line_sync() 导致您的 CPU 暂时加速?我会尝试拨打 async 电话,只是为了检查一下。

顺便说一句,请参阅 util.js,它有一个函数 spawnCommandLine(),它异步运行命令并自动处理错误。导入是 imports.misc.util;.

如果使用异步调用解决了您的 CPU 高问题,我很想听听。