How to use the systeminformation.battery function in systeminformation

To help you get started, we’ve selected a few systeminformation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Polymer / tachometer / src / json-output.ts View on Github external
export async function legacyJsonOutput(results: BenchmarkResult[]):
    Promise {
  // TODO Add git info.
  const battery = await systeminformation.battery();
  const cpu = await systeminformation.cpu();
  const currentLoad = await systeminformation.currentLoad();
  const memory = await systeminformation.mem();
  return {
    benchmarks: results,
    datetime: new Date().toISOString(),
    system: {
      cpu: {
        manufacturer: cpu.manufacturer,
        model: cpu.model,
        family: cpu.family,
        speed: cpu.speed,
        cores: cpu.cores,
      },
      load: {
        average: currentLoad.avgload,
github sbuggay / sentry / packages / sentry-server-data / src / Server.ts View on Github external
export async function dynamicInfo(): Promise {
	const osData = {
		hostname: os.hostname(),
		uptime: os.uptime(),
		freemem: os.freemem(),
		totalmem: os.totalmem(),
		cpus: os.cpus(),
		loadavg: os.loadavg()
	}

	const promises = [
		si.battery(),
		si.graphics(),
		si.osInfo(),
		si.fsSize(),
		si.cpuTemperature()
	];

	const [battery, graphics, osInfo, fsSize, cpuTemp] = await Promise.all(promises);
	return {
		...osData,
		battery,
		graphics,
		osInfo,
		fsSize,
		cpuTemp
	};
github GoogleChromeLabs / carlo / examples / systeminfo / app.js View on Github external
async function systeminfo() {
  const info = {};
  await Promise.all([
    si.battery().then(r => info.battery = r),
    si.cpu().then(r => info.cpu = r),
    si.osInfo().then(r => info.osInfo = r),
  ]);
  return info;
}
github ruslang02 / atomos / apps / official / batterymeter / batterymeter.js View on Github external
function updateBattery() {
	return si.battery().then(data => {
        if (!data.model) {
			clearInterval(batteryTimer);
            return;
        }
		let icon = Math.round(data.percent / 10) * 10;
		if (icon === 100) icon = "battery";
		else if (icon === 0) icon = "battery-outline";
		else icon = "battery-" + icon;
        if (data.ischarging) icon = icon.replace("battery", "battery-charging");
        let isPerc = !!Registry.get("system.showBatteryPercentage");
        let iconSize = isPerc ? 18 : 24;
        let hours = Math.trunc(data.timeremaining / 60);
        let minutes = data.timeremaining - Math.trunc(data.timeremaining / 60) * 60;
        let time = hours > 0 ? hours + " hours" + (minutes > 0 ? " " + minutes + " minutes" : "") : (minutes > 0 ? minutes + " minutes" : "Not available");
        let status = (data.percent > 49 || data.ischarging) ? "success" : (data.percent > 19 ? "warning" : "danger");
        button.icon.className = `mdi mdi-${iconSize}px d-flex lh-${iconSize} mdi-${icon}`;