From 68ec5c50a623c65f3b9f8037b2ce55e215bceb02 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 9 Aug 2025 15:34:43 +0545 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(panel):=20display=20battery=20?= =?UTF-8?q?percentage=20next=20to=20the=20battery=20icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/panel/components/indicators.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/panel/components/indicators.py b/modules/panel/components/indicators.py index 524f4d9..8bdba52 100644 --- a/modules/panel/components/indicators.py +++ b/modules/panel/components/indicators.py @@ -2,13 +2,15 @@ from fabric.bluetooth import BluetoothClient from fabric.utils import get_relative_path from fabric.widgets.box import Box from fabric.widgets.button import Button +from fabric.widgets.label import Label from fabric.widgets.svg import Svg + +from modules.controlcenter.battery import BatteryControl +from modules.controlcenter.bluetooth import BluetoothConnections +from modules.controlcenter.wifi import WifiConnections from services.battery import Battery from services.network import NetworkClient from utils.roam import modus_service -from modules.controlcenter.wifi import WifiConnections -from modules.controlcenter.bluetooth import BluetoothConnections -from modules.controlcenter.battery import BatteryControl from widgets.mousecapture import DropDownMouseCapture from widgets.wayland import WaylandWindow as Window @@ -350,6 +352,9 @@ class BatteryIndicator(Box): on_clicked=self.on_battery_clicked, ) + self.battery_label = Label(name="battery-label", label="--- %") + + self.add(self.battery_label) self.add(self.battery_button) # Create Battery control center widget only if show_window is True @@ -431,6 +436,7 @@ class BatteryIndicator(Box): if not self.battery_service.is_present: icon_file = "battery.svg" tooltip = "No battery detected" + percentage_text = "N/A" else: percentage = self.battery_service.percentage state = self.battery_service.state @@ -440,10 +446,12 @@ class BatteryIndicator(Box): percentage, is_charging, base_path="../../../config/assets/icons/" ) tooltip = self.get_battery_tooltip(percentage, state) + percentage_text = f"{percentage}%" - # Update icon and tooltip + # Update icon, tooltip, and percentage label self.battery_icon.set_from_file(get_relative_path(icon_file)) self.battery_button.set_tooltip_text(tooltip) + self.battery_label.set_label(percentage_text) def on_battery_clicked(self, *args): """Handle Battery indicator click"""