Skip to content

Commit 9ac417d

Browse files
committed
more precise info
1 parent 1c53873 commit 9ac417d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

extension.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const St = imports.gi.St;
22
const PanelMenu = imports.ui.panelMenu;
3-
const PopupMenu = imports.ui.popupMenu;
43
const Main = imports.ui.main;
54
const Lang = imports.lang;
65
const GLib = imports.gi.GLib;
@@ -10,7 +9,6 @@ const Shell = imports.gi.Shell;
109
const Clutter = imports.gi.Clutter
1110

1211
const POWER_NOW = "/sys/class/power_supply/BAT0/power_now";
13-
const WINDOW_SIZE = 100;
1412

1513
let meta;
1614
let tp_wattmeter;
@@ -26,7 +24,7 @@ var TPWattMeter = class TPWattMeter extends PanelMenu.Button {
2624
super._init(St.Align.START);
2725
this.mainBox = null;
2826
this.buttonText = new St.Label({
29-
text: _("?W"),
27+
text: _("?W"),
3028
y_align: Clutter.ActorAlign.CENTER,
3129
style_class: 'tp_wattmeter_lbl',
3230
});
@@ -41,11 +39,7 @@ var TPWattMeter = class TPWattMeter extends PanelMenu.Button {
4139
this.powerWindows = [];
4240
return true;
4341
}
44-
4542
this.powerWindows.push(power);
46-
if (this.powerWindows.length >= WINDOW_SIZE) {
47-
this.powerWindows.shift();
48-
}
4943
return true;
5044
}
5145
_refresh() {
@@ -56,7 +50,10 @@ var TPWattMeter = class TPWattMeter extends PanelMenu.Button {
5650
power_text = this.lastStatus != null ? this.lastStatus : 'N/A';
5751
} else {
5852
let avg = this.powerWindows.reduce((acc, elem) => acc + elem, 0.0) / this.powerWindows.length;
59-
power_text = avg.toFixed(2) + 'W'
53+
while (this.powerWindows.length) { this.powerWindows.pop(); };
54+
this.powerWindows.push(avg);
55+
56+
power_text = avg.toFixed(2) + 'W';
6057
}
6158

6259
temp.set_text(power_text);

0 commit comments

Comments
 (0)