fix: correct battery icons
This commit is contained in:
@@ -96,13 +96,13 @@ class StatusBar(Window):
|
|||||||
if self.vinyl:
|
if self.vinyl:
|
||||||
end_container_children.append(self.vinyl)
|
end_container_children.append(self.vinyl)
|
||||||
|
|
||||||
if self.battery:
|
|
||||||
end_container_children.append(self.battery)
|
|
||||||
|
|
||||||
end_container_children.append(self.status_container)
|
end_container_children.append(self.status_container)
|
||||||
if self.system_tray:
|
if self.system_tray:
|
||||||
end_container_children.append(self.system_tray)
|
end_container_children.append(self.system_tray)
|
||||||
|
|
||||||
|
if self.battery:
|
||||||
|
end_container_children.append(self.battery)
|
||||||
|
|
||||||
end_container_children.append(self.date_time)
|
end_container_children.append(self.date_time)
|
||||||
|
|
||||||
self.children = CenterBox(
|
self.children = CenterBox(
|
||||||
|
|||||||
@@ -35,15 +35,10 @@ class Battery(Box):
|
|||||||
self.bat_provider = BatteryProvider()
|
self.bat_provider = BatteryProvider()
|
||||||
|
|
||||||
self.bat_icon = Image(
|
self.bat_icon = Image(
|
||||||
name="bat-icon",
|
name="bat-icon", icon_name="battery-full-symbolic", icon_size=16
|
||||||
icon_name="battery-full-symbolic",
|
|
||||||
icon_size=16
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.bat_label = Label(
|
self.bat_label = Label(name="bat-label", label="100%")
|
||||||
name="bat-label",
|
|
||||||
label="100%"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.bat_fabricator = Fabricator(
|
self.bat_fabricator = Fabricator(
|
||||||
poll_from=lambda *_: self.bat_provider.get_battery(),
|
poll_from=lambda *_: self.bat_provider.get_battery(),
|
||||||
@@ -59,28 +54,13 @@ class Battery(Box):
|
|||||||
GLib.idle_add(self.update_battery, None, self.bat_provider.get_battery())
|
GLib.idle_add(self.update_battery, None, self.bat_provider.get_battery())
|
||||||
|
|
||||||
def _icon_lookup(self, bat, charging):
|
def _icon_lookup(self, bat, charging):
|
||||||
|
# Round to nearest 10 for level-based icons
|
||||||
|
level = max(10, min(100, round(bat / 10) * 10))
|
||||||
|
|
||||||
if charging:
|
if charging:
|
||||||
if bat >= 100:
|
return f"battery-level-{level}-charging-symbolic"
|
||||||
return "battery-full-charging-symbolic"
|
|
||||||
elif bat > 70:
|
|
||||||
return "battery-good-charging-symbolic"
|
|
||||||
elif bat > 40:
|
|
||||||
return "battery-medium-charging-symbolic"
|
|
||||||
elif bat > 20:
|
|
||||||
return "battery-low-charging-symbolic"
|
|
||||||
else:
|
else:
|
||||||
return "battery-caution-charging-symbolic"
|
return f"battery-level-{level}-symbolic"
|
||||||
else:
|
|
||||||
if bat >= 100:
|
|
||||||
return "battery-full-symbolic"
|
|
||||||
elif bat > 70:
|
|
||||||
return "battery-good-symbolic"
|
|
||||||
elif bat > 40:
|
|
||||||
return "battery-medium-symbolic"
|
|
||||||
elif bat > 20:
|
|
||||||
return "battery-low-symbolic"
|
|
||||||
else:
|
|
||||||
return "battery-caution-symbolic"
|
|
||||||
|
|
||||||
def update_battery(self, sender, battery_data):
|
def update_battery(self, sender, battery_data):
|
||||||
value, charging = battery_data
|
value, charging = battery_data
|
||||||
|
|||||||
Reference in New Issue
Block a user