Skip to content

feat(battery): add option to set unlimited time remaining icon/text#670

Open
stylebending wants to merge 4 commits intoamnweb:mainfrom
stylebending:battery-unlimited-icon
Open

feat(battery): add option to set unlimited time remaining icon/text#670
stylebending wants to merge 4 commits intoamnweb:mainfrom
stylebending:battery-unlimited-icon

Conversation

@stylebending
Copy link

Hi! This PR addresses the request in Discussion #663.

I’ve added a new configurable icon, icon_unlimited, to the battery widget's status_icons. This allows users to choose between the default "unlimited" text or the infinity icon "∞" (or any other string/icon) for a cleaner taskbar look.

Changes:

  • Added icon_unlimited to DEFAULTS and VALIDATION_SCHEMA.
  • Updated _get_time_remaining to pull the value dynamically from the user's configuration.
  • Updated the battery widget docs to explain the option.
  • Default behavior remains as "unlimited" to maintain backward compatibility.

@Video-Nomad
Copy link
Contributor

Hi! Thanks for the PR. We recently moved from Cerberus to Pydantic for validation files. Please check the new battery validation schema format.

@stylebending
Copy link
Author

stylebending commented Feb 4, 2026

Hi! Thanks for the PR. We recently moved from Cerberus to Pydantic for validation files. Please check the new battery validation schema format.

Thanks for pointing that out! I've updated the battery validation schema and the widget's _get_time_remaining function to match the new project standard. This is now ready for another review.

Copy link
Contributor

@Video-Nomad Video-Nomad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as described, however my problem with this change is that we are adding an icon to the status_icons but it's not a status icon {icon} . It's a separate {time_remaining}. It does not have specific styling like other icons. It's more similar to charging_options to be honest, so it might be a better idea to expand this and make something like:

time_remaining_options:
  time_format: <- Standard python time formatting string like "%H:%M:%S"
  unlimited_icon: <- Unlimited icon

We can't really move current time_remaining_natural as it will break configurations, but time_format can be overridden by it if it's true. Ideally it would go to the same time_remaining_options.
@amnweb What do you think about this?

@amnweb
Copy link
Owner

amnweb commented Feb 8, 2026

@Video-Nomad I'm fine with any option you choose since I only have a battery device when I mock one D
Not sure if you really need %S there, but if this report shows the correct remaining time then it's ok.

@Video-Nomad
Copy link
Contributor

@stylebending So I guess to not overcomplicate this too much and since we already have time_remaining_natural I think just renaming the icon_unlimited -> time_remaining_unlimited_icon and putting it right under time_remaining_natural would make more sense. Just to separate it from status_icons. And leave it at that.

battery:
  type: "yasb.battery.BatteryWidget"
  options:
    time_remaining_natural: False
    time_remaining_unlimited_icon: "\u221e"

@stylebending
Copy link
Author

@Video-Nomad Thanks for taking a look at this again! I've made these changes:

  • Renamed icon_unlimited to time_remaining_unlimited_icon.
  • Moved it from status_icons to right under time_remaining_natural.
  • Edited the widget's documentation to represent this correctly.

I believe this is ready now, if there's anything else that needs to be changed, I would love to hear it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants