Battery Window Enhanced

This commit is contained in:
tr1x_em committed 2025-08-11 11:28:23 +05:30
1 parent f4349e6d93
commit 66464df825
2 files changed
+81 -32

No files matched your search

+17 -12
View File
@@ -44,14 +44,14 @@ class EnergyModeButton(Box):
self.mode_label = Label(
label=display_name,
style_classes="battery-power-source",
style_classes="battery-power-mode",
h_align="start",
h_expand=True,
)
start_box = Box(
orientation="horizontal",
spacing=8,
spacing=4,
children=[self.mode_icon, self.mode_label],
)
@@ -88,7 +88,7 @@ class EnergyModeButton(Box):
class GameModeButton(Box):
def __init__(self, parent, **kwargs):
super().__init__(name="game-mode-button", h_expand=True, **kwargs)
super().__init__(name="energy-mode-button", h_expand=True, **kwargs)
self.parent = parent
self.game_icon = Image(
@@ -100,14 +100,14 @@ class GameModeButton(Box):
self.game_label = Label(
label="Game Mode",
style_classes="battery-power-source",
style_classes="gamemode-button",
h_align="start",
h_expand=True,
)
start_box = Box(
orientation="horizontal",
spacing=8,
spacing=3,
children=[self.game_icon, self.game_label],
)
@@ -164,7 +164,7 @@ class BatteryControl(Box):
name="control-center-widgets",
**kwargs,
)
self.set_size_request(400, -1)
self.set_size_request(374, -1)
self.parent = parent
self.battery_service = Battery()
@@ -229,9 +229,9 @@ class BatteryControl(Box):
)
self.battery_settings_button = Button(
v_align="center",
child=Label(
label="Battery Settings...",
style_classes="battery-power-source",
label="Battery Settings",
h_align="start",
),
style_classes="battery-settings-button",
@@ -358,10 +358,10 @@ class BatteryControl(Box):
# Update power source and charging info
state = self.battery_service.state
if state == "CHARGING":
if state in ["CHARGING", "PENDING_CHARGE"]:
self.power_source_label.set_label("Power Source: Power Adapter")
time_to_full = self.battery_service.time_to_full
if time_to_full != "N/A":
if time_to_full != "N/A" and time_to_full != "0m":
self.charging_time_label.set_label(
f"{time_to_full} until fully charged"
)
@@ -370,13 +370,18 @@ class BatteryControl(Box):
elif state == "FULLY_CHARGED":
self.power_source_label.set_label("Power Source: Power Adapter")
self.charging_time_label.set_label("Fully Charged")
elif state == "DISCHARGING":
elif state in ["DISCHARGING", "PENDING_DISCHARGE"]:
self.power_source_label.set_label("Power Source: Battery")
time_to_empty = self.battery_service.time_to_empty
if time_to_empty != "N/A":
if time_to_empty != "N/A" and not time_to_empty.startswith(
"4553h"
): # Filter out unrealistic times
self.charging_time_label.set_label(f"{time_to_empty} remaining")
else:
self.charging_time_label.set_label("On Battery Power")
elif state == "EMPTY":
self.power_source_label.set_label("Power Source: Battery")
self.charging_time_label.set_label("Battery Empty")
else:
self.power_source_label.set_label("Power Source: Unknown")
self.charging_time_label.set_label("")
+64 -20
View File
@@ -1,6 +1,12 @@
#battery-widget {
padding-left: 12px;
padding-right: 12px;
}
.battery-main-title {
font-size: 1em;
font-weight: 900;
font-size: 16px;
font-family: "SF Pro Rounded";
font-weight: bold;
color: rgba(255, 255, 255, 0.95);
margin: 6px 10px;
}
@@ -33,16 +39,11 @@
}
.battery-percentage {
font-size: 1.4em;
font-weight: 600;
color: rgba(255, 255, 255, 0.95);
}
.battery-section-title {
font-size: 0.95em;
font-size: 16px;
font-family: "SF Pro Rounded";
margin-right: 8px;
font-weight: 500;
color: rgba(255, 255, 255, 0.9);
margin: 0px 10px;
color: rgba(255, 255, 255, 0.95);
}
#energy-mode-button-clickable {
@@ -51,7 +52,6 @@
border-radius: 8px;
padding: 6px 12px;
margin: 1px 0;
transition: all 0.2s ease;
}
#energy-mode-button-clickable:hover {
@@ -61,26 +61,72 @@
#energy-mode-icon {
border-radius: 50%;
padding: 4px;
margin-right: 8px;
margin-top: -2px;
margin-bottom: -2px;
margin-right: 6px;
margin-left: -6px;
background-color: rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.7);
transition: all 0.2s ease;
}
#energy-mode-icon.connected {
background-color: #007aff;
color: #ffffff;
}
.battery-power-source {
font-size: 12px;
font-family: "SF Pro Rounded";
margin-bottom: -4px;
color: alpha(#ffffff, 0.5);
}
.battery-section-title {
font-size: 14px;
font-family: "SF Pro Rounded";
color: alpha(#ffffff, 0.7);
margin: 2px 0 0 8px;
}
.battery-power-mode {
font-family: "SF Pro Rounded";
font-size: 13px;
}
#energy-mode-button .battery-power-source {
margin: 0;
font-size: 0.9em;
.battery-settings-button:hover {
margin-top: -5px;
background: alpha(#ffffff, 0.1);
min-height: 30px;
border-radius: 8px;
}
.battery-settings-button {
margin-top: -5px;
min-height: 30px;
border-radius: 8px;
}
.battery-settings-button label {
font-family: "SF Pro Rounded";
font-weight: 500;
color: alpha(#ffffff, 1);
}
#energy-mode-button:first-child {
margin-top: 0;
}
#energy-mode-button {
margin-top: -8px;
margin-bottom: 4px;
color: rgba(255, 255, 255, 0.85);
}
.gamemode-button {
font-size: 12px;
font-family: "SF Pro Rounded";
margin-left: -6px;
color: rgba(255, 255, 255, 0.85);
}
#game-mode-button {
margin: 2px 0;
}
#game-mode-icon {
margin-left: -6px;
}
#game-mode-button-clickable {
background: transparent;
@@ -88,7 +134,6 @@
border-radius: 8px;
padding: 6px 12px;
margin: 1px 0;
transition: all 0.2s ease;
/* min-height: 36px; */
}
@@ -102,10 +147,9 @@
margin-right: 8px;
background-color: rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.7);
transition: all 0.2s ease;
}
#game-mode-icon.connected {
background-color: #ff4500;
background-color: #007aff;
color: #ffffff;
}