npm install macos-system-info
or
yarn add macos-system-info
You can find the documentation here.
This little code snipped shows how to read the current CPU temperature:
// import the class
const { SystemInfo } = require('macos-system-info');
// create a new instance of the class and open the connection to the SMC
const systemInfo = new SystemInfo();
systemInfo.open();
// read the cpu temperature
console.log(systemInfo.getCpuTemp());
// close the connection to the SMC
systemInfo.close();
If you are using typescript you can use named imports:
// import the class
import { SystemInfo } from 'macos-system-info';
// create a new instance of the class and open the connection to the SMC
const systemInfo: SystemInfo = new SystemInfo();
systemInfo.open();
// read the cpu temperature
console.log(systemInfo.getCpuTemp());
// close the connection to the SMC
systemInfo.close();
Generated using TypeDoc