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

SunkenHero Code optimization & addition of battery percentage #432

Merged
merged 16 commits into from Sep 10, 2022

Conversation

SunkenHero
Copy link
Contributor

@SunkenHero SunkenHero commented Sep 8, 2022

A few code optimizations

  • Temperatures are more generic
  • Now using psutil to get charging status
  • Now showing battery percentage

@SunkenHero SunkenHero changed the title Optimizations in temperature SunkenHero a few code optimizations Sep 8, 2022
@SunkenHero
Copy link
Contributor Author

I hope the code isn't too bad, i am not so experienced as i am only 15 years old.

@@ -42,9 +42,6 @@
)
CPUS = os.cpu_count()

# ignore these devices under /sys/class/power_supply/
POWER_SUPPLY_IGNORELIST = ["hidpp_battery"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think its not needed anymore, but i am not sure

Copy link
Owner

Choose a reason for hiding this comment

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

I think we do still need it, check #332 PR for reference.

# If found in ignore list, skip it.
if ignore_supply:
continue
return True if psutil.sensors_battery().power_plugged else False

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using psutil to get charging status

Copy link
Owner

Choose a reason for hiding this comment

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

As I mentioned in other comment this was all added with #308 as battery state would not be showing properly on certain devices, still thinking if we might need some of it or if psutil will be able to pick it all up itself ...

"""
get batery percentage
"""
return psutil.sensors_battery().percent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added Function to get Battery Percentage

Copy link
Owner

Choose a reason for hiding this comment

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

Another reference on why it was the way it was done in the past #308

@SunkenHero
Copy link
Contributor Author

Completely tested it on my laptop without encountering any errors

@AdnanHodzic
Copy link
Owner

I hope the code isn't too bad, i am not so experienced as i am only 15 years old.

This is great, and I encourage you stay on this path and you'll get far in life :)

I reviewed your changes and left few comments on everything, please take a look.

If you haven't seen it already and if you plan on sticking around for awhile I also encourage you to take a look at: https://github.com/AdnanHodzic/auto-cpufreq#looking-for-developers-and-co-maintainers

@SunkenHero
Copy link
Contributor Author

Ok i will fix the problems and in the future i will check for issues before changing the code

@SunkenHero
Copy link
Contributor Author

so i fixed all problems, and i think its ready for the merge

@AdnanHodzic AdnanHodzic changed the title SunkenHero a few code optimizations SunkenHero Code optimization & addition of battery percentage Sep 10, 2022
@AdnanHodzic AdnanHodzic merged commit 98569ad into AdnanHodzic:master Sep 10, 2022
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.

None yet

2 participants