BatteryPanel: use BarService instead of custom for loops.

This commit is contained in:
Lemmy
2025-12-13 15:02:26 -05:00
parent 6b2661e1d4
commit 6459a5026b
+3 -18
View File
@@ -19,24 +19,9 @@ SmartPanel {
// Get device selection from Battery widget settings (check right section first, then any Battery widget)
function getBatteryDevicePath() {
// Check right section first (most common location for Battery widget)
var rightWidgets = Settings.data.bar.widgets.right || [];
for (var i = 0; i < rightWidgets.length; i++) {
var widget = rightWidgets[i];
if (widget && widget.id === "Battery" && widget.deviceNativePath) {
return widget.deviceNativePath;
}
}
// Check other sections
var sections = ["left", "center"];
for (var s = 0; s < sections.length; s++) {
var widgets = Settings.data.bar.widgets[sections[s]] || [];
for (var j = 0; j < widgets.length; j++) {
var widget = widgets[j];
if (widget && widget.id === "Battery" && widget.deviceNativePath) {
return widget.deviceNativePath;
}
}
var widget = BarService.lookupWidget("Battery");
if (widget !== undefined) {
return widget.deviceNativePath;
}
return "";
}