couple of changes 😓

This commit is contained in:
Thomas Ruoff
2021-11-28 23:49:31 +01:00
parent 662fa3f5b1
commit c0af622d2b
8 changed files with 27 additions and 21 deletions

View File

@@ -1,14 +1,18 @@
#!/usr/bin/env node
'use strict';
var linuxBattery = require('linux-battery');
const linuxBattery = require('linux-battery');
async function run() {
try {
const batteries = await linuxBattery();
batteries.forEach(battery => {
var color = battery.warningLevel !== 'none' ? '#ff0000' : '#eee8d5';
var stateSymbol = battery.state === 'charging' ? '↑' : '↓';
if (battery.powerSupply === 'no') {
return '';
}
const color = battery.warningLevel !== 'none' ? '#ff0000' : '#eee8d5';
let stateSymbol = battery.state === 'charging' ? '↑' : '↓';
switch (battery.state) {
case 'charging':
stateSymbol = '↑';
@@ -22,9 +26,9 @@ async function run() {
default:
}
var timeLeft = battery.timeToFull || battery.timeToEmpty || '';
const timeLeft = battery.timeToFull || battery.timeToEmpty || '';
var text = `%{F${color}}${battery.percentage} ${stateSymbol} ${timeLeft}%{F-}`;
const text = `%{F${color}}${battery.percentage} ${stateSymbol} ${timeLeft}%{F-}`;
process.stdout.write(text);
});
} catch (error) {