Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // -*- coding: utf-8 -*-
- // Filename: batstats.js
- // Version: 1.0.0
- // Author: Jeoi Reqi
- // This script retrieves battery information.
- // The script presents battery details like status and charge level clearly.
- // Users can quickly gauge battery health and make informed decisions about power usage.
- // Example Output:
- // --------------------------------------------------
- // :: BATTERY STATS ::
- // --------------------------------------------------
- //
- // Internal Battery: [AP18E8M] Status: OK
- // Battery Status: Connected to AC (2)
- // Charge Remaining: 95%
- //
- // --------------------------------------------------
- console.log("-".repeat(50));
- console.log("\t\t:: BATTERY STATS ::");
- console.log("-".repeat(50));
- const batteryStatus = {
- 1: 'Discharging',
- 2: 'Connected to AC',
- 3: 'Fully charged',
- 4: 'Low',
- 5: 'Critical',
- 6: 'Charging',
- 7: 'Charging/High',
- 8: 'Charging/Low',
- 9: 'Charging/Critical',
- 10: 'Undefined',
- 11: 'Partially Charged'
- };
- // Assuming battery information is obtained from an API call
- const battery = {
- Caption: 'Internal Battery',
- Name: 'AP18E8M',
- Status: 'OK',
- BatteryStatus: 2,
- EstimatedChargeRemaining: 95
- };
- const batteryStatusDescription = batteryStatus[battery.BatteryStatus] || 'Unknown';
- // Print battery information header
- console.log("");
- console.log(`${battery.Caption}: [${battery.Name}] Status: ${battery.Status}`);
- console.log(`Battery Status: ${batteryStatusDescription} (${battery.BatteryStatus})`);
- console.log(`Charge Remaining: ${battery.EstimatedChargeRemaining}%\n`);
- console.log("-".repeat(50));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement