Merge pull request #2673 from olivierbarriere/master

Vertical Battery Widget: make color depend on level
master
Gordon Williams 2023-04-03 09:53:01 +01:00 committed by GitHub
commit a058c22108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -1 +1,2 @@
0.01: New widget
0.02: Make color depend on level

View File

@ -1,7 +1,7 @@
{
"id": "widbatv",
"name": "Battery Level Widget (Vertical)",
"version": "0.01",
"version": "0.02",
"description": "Slim, vertical battery widget that only takes up 14px",
"icon": "widget.png",
"type": "widget",

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);
}
}};