Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/widgets/(Widget)-Battery.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| `class_name` | string | `""` | Additional CSS class name for the widget. |
| `update_interval` | integer | `5000` | The interval in milliseconds to update the widget. |
| `time_remaining_natural`| boolean | `False` | Whether to display the remaining time in a natural format. |
| `time_remaining_unlimited_icon`| string | `unlimited` | Which string to use to display unlimited time remaining. |
| `hide_unsupported`| boolean | `True` | Whether to hide the widget if the current system does not have battery info. |
| `charging_options` | dict | `{icon_format: '{charging_icon}', blink_charging_icon: True, blink_interval: 500}` | Options for charging state display. |
| `status_thresholds` | dict | `{critical: 10, low: 25, medium: 75, high: 95, full: 100}` | Thresholds for different battery statuses. |
Expand Down Expand Up @@ -78,6 +79,7 @@ battery:
- **class_name**: Additional CSS class name for the widget. This allows for custom styling.
- **update_interval**: The interval in milliseconds to update the widget.
- **time_remaining_natural**: A boolean indicating whether to display the remaining time in a natural format.
- **time_remaining_unlimited_icon**: A string to display unlimited time remaining.
- **hide_unsupported**: A boolean indicating whether to hide the widget if the current system does not have battery information.
- **charging_options**: A dictionary specifying options for displaying the charging state. It contains:
- **icon_format**: The format string for the charging icon. You can use placeholders like `{charging_icon}` and `{icon}`.
Expand Down Expand Up @@ -173,4 +175,4 @@ battery:
.battery-widget .label.status-charging {
color: #4dd0e1;
}
```
```
1 change: 1 addition & 0 deletions src/core/validation/widgets/yasb/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class BatteryConfig(CustomBaseModel):
class_name: str = ""
update_interval: int = Field(default=5000, ge=0, le=60000)
time_remaining_natural: bool = False
time_remaining_unlimited_icon: str = "unlimited"
hide_unsupported: bool = True
charging_options: ChargingOptionsConfig = ChargingOptionsConfig()
status_thresholds: StatusThresholdsConfig = StatusThresholdsConfig()
Expand Down
2 changes: 1 addition & 1 deletion src/core/widgets/yasb/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _toggle_label(self):
def _get_time_remaining(self) -> str:
secs_left = self._battery_state.time_remaining
if secs_left == POWER_TIME_UNLIMITED:
time_left = "unlimited"
time_left = self.config.time_remaining_unlimited_icon
elif secs_left == POWER_TIME_UNKNOWN:
time_left = "unknown"
elif secs_left >= 0:
Expand Down