Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for hot-swapping batteries and allowing missing batteries without errors #835

Merged
merged 4 commits into from
Sep 30, 2020

Conversation

Nukesor
Copy link
Contributor

@Nukesor Nukesor commented Sep 28, 2020

Hi!

First of all, thanks for providing this project! Looks great and it really has a super low memory/processing power footprint.

This PR is a follow-up to the other two existing battery PRs.
#233
#585

The idea of this PR is to allow several new things, but all visible changes will be hidden behind configurable feature flags.

The PR is based on #585. Thanks to @flying7eleven for providing an easy entry point to this whole issue.

There are three issues, each addressed in it's own commit:

  1. Users should decide, whether they want to ignore if a battery is missing or not. The current error message kills the whole bar and forces the user to reload i3.
    This issue has been solved by introducing a new configuration flag allow_missing_battery. If set to true, there will be a simple placeholder text instead of crashing the whole bar.
  2. Users should be able to completely hide the widget, if a battery goes missing.
    This is something that comes from people using the same configuration accross several devices.
    I myself, for instance, have two laptops (one at work, one at home) and one of them has a single battery, the other one has two.
    This change simply enhances the ergonomics for users with multiple devices.
  3. Hot-swapping batteries.
    This needed a few more changes, since some values of the battery were previously only read once during initialization.
    Since hot-swapping can change the specs of a battery device, these values now have to be read continuously.

GIF of a hot-swap in action.
Peek 2020-09-29 12-33

GIF of a hot-swap with hide_missing = true
Peek 2020-09-30 15-31
`

@Brod8362
Copy link

This is great! I was just thinking of this the other day, having a battery that may not always be present shouldn't break the entire bar.

@ammgws
Copy link
Collaborator

ammgws commented Sep 30, 2020

Yeah I think this is the best we can do, thank you @Nukesor and @flying7eleven for the clear overview and work on this issue. Perhaps it would be nice to add another format string to use when allow_missing_battery is turned on so one could have it display something other than "X%" or "xx:xx" when the battery is missing (like the KDEConnect block's format_disconnected option).

blocks.md Outdated Show resolved Hide resolved
blocks.md Outdated Show resolved Hide resolved
@ammgws
Copy link
Collaborator

ammgws commented Sep 30, 2020

Also could you share a gif or image of what the bar looks like with hide_missing is used?

@ammgws ammgws linked an issue Sep 30, 2020 that may be closed by this pull request
1. Rename `allow_missing_battery` to `allow_missing`.
2. Rename `hidem_missing_battery` to `hide_missing`.
3. Add new `missing_format` string which will be used
     whenever a battery is missing.
4. Add documentation for some missing configuration variables.
@Nukesor
Copy link
Contributor Author

Nukesor commented Sep 30, 2020

Hey :)
I renamed the parameters from *_missing_battery to *_missing. Those are indeed better names!

On top of that the new missing_format string has been added. This has been tested and works as intended.

I also added a few missing parameters to blocks.md in this commit.

A gif of a hot-swap with hide_missing has been added to the original post :)

@ammgws
Copy link
Collaborator

ammgws commented Sep 30, 2020

LGTM

Thanks!

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

Successfully merging this pull request may close these issues.

Account for not having a battery
4 participants