Skip to content

Fix battery refresh when swapping power (issue #839 and #1181)#1306

Open
koppa wants to merge 1 commit into
polybar:masterfrom
koppa:battery_fix
Open

Fix battery refresh when swapping power (issue #839 and #1181)#1306
koppa wants to merge 1 commit into
polybar:masterfrom
koppa:battery_fix

Conversation

@koppa

@koppa koppa commented Jul 6, 2018

Copy link
Copy Markdown

Here is a fix for correcting the behavior of polybar when suspending.

The paths for monitoring the battery state can change in a running system,
for example after a suspend.

Therefore now the battery module now tries to find the correct battery paths
after a failing inotify watch.

For the implementation i merged the logic of the inotify_module into the battery modules
for an easy fix.

TEAM EDIT: Fixes #1937

* Merge the inotify_module class inside the battery_module
    This allows further extension of the class
* Recreate battery on missing paths
@koppa koppa changed the title Fix battery refresh when swapping power /(issue #839 and #1181) Fix battery refresh when swapping power (issue #839 and #1181) Jul 8, 2018

@f0s3 f0s3 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code is fine, I haven't noticed anything wrong while testing and reviewing it. Some part of indentation was changed (which does not relate to the bug fix). I think that if you create a new PR that fixes the indentation, I will review and approve it.

Comment thread include/modules/battery.hpp
protected:
void runner() {
this->m_log.trace("%s: Thread id = %i", this->name(), concurrency_util::thread_id(this_thread::get_id()));
public: using module<Impl>::module; void start() { this->m_mainthread = thread(&inotify_module::runner, this); } protected: void runner() { this->m_log.trace("%s: Thread id = %i", this->name(), concurrency_util::thread_id(this_thread::get_id()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Leave the indentation as it was, it is difficult to review and, possibly, introduces useless changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Strange that it was all put on the same line. Did clang-format do that?

Comment thread src/modules/battery.cpp
@patrick96

Copy link
Copy Markdown
Member

@f0s3 Thanks for the review. I will also take a last look once I have some time.

The formatting changes are introduced by clang-format and we want people to run it on the files they have changed: https://github.com/polybar/polybar/wiki/Style-Guide#code-formatting

We are currently trying to get all our code formatted with clang-format but because we don't want to introduce a bunch of conflicts in all open PRs we didn't want to just format everything at once, so we ask contributors to format the files they changed with clang-format. This way all files get formatted one-by-one and at some point we can then run clang-format to also format the files that are never touched by anyone.

Though the one where everything moved onto the same line seems out of place and shouldn't be something that clang-format does.

@pstch

pstch commented May 19, 2020

Copy link
Copy Markdown

I'm using this patch on my laptop, and it seems to be working fine (fixes the problem in #1937).

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.

Broken battery controllers (handling module resets)

4 participants