fix statusbar

This commit is contained in:
Thomas Ruoff
2020-03-15 22:43:24 +01:00
parent a15873ebb3
commit 640f159022
3 changed files with 16 additions and 2 deletions

View File

@@ -7,9 +7,22 @@ linuxBattery().then(batteries => {
batteries.forEach(battery => {
var color = battery.warningLevel !== 'none' ? '#ff0000' : '#eee8d5';
var stateSymbol = battery.state === 'charging' ? '↑' : '↓';
switch (battery.state) {
case 'charging':
stateSymbol = '↑';
break;
case 'fully-charged':
stateSymbol = 'F';
break;
case 'discharging':
stateSymbol = '↓';
break;
default:
}
var timeLeft = battery.timeToFull || battery.timeToEmpty || '';
var text = `%{F${color}}${battery.percentage} ${stateSymbol} ${timeLeft}%{F-}`;
console.log(text);
process.stdout.write(text);
});
});