Vertical Battery Widget: make color depend on level

master
olivierbarriere 2023-03-27 11:31:15 -04:00 committed by GitHub
parent 0ce0b9e22b
commit 66e4a01bf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,10 @@ WIDGETS["batv"]={area:"tr",width:14,draw:function() {
} else {
g.clearRect(x,y,x+14,y+24);
g.setColor(g.theme.fg).fillRect(x+2,y+2,x+12,y+22).clearRect(x+4,y+4,x+10,y+20).fillRect(x+5,y+1,x+9,y+2);
g.setColor("#0f0").fillRect(x+4,y+20-(E.getBattery()*16/100),x+10,y+20);
var battery = E.getBattery();
if (battery < 20) {g.setColor("#f00");}
else if (battery < 40) {g.setColor(g.theme.dark ? "#ff0" : "#f80");}
else {g.setColor("#0f0");}
g.fillRect(x+4,y+20-(E.getBattery()*16/100),x+10,y+20);
}
}};