boramalper / himawaripy

Set near-realtime picture of Earth as your desktop background
http://labs.boramalper.org/himawaripy
MIT License
1.62k stars 239 forks source link

Do not download the page while battery discharging #81

Closed vician closed 7 years ago

vician commented 7 years ago

I don't want to use himawaripy while my battery is discharging.

jcmiller11 commented 7 years ago

If this feature is added I think it needs a flag in config.py to allow the user to configure if they want this functionality.

Additionally, I know your implementation will work on Debian/Ubuntu based distros, but I'm not sure it is entirely portable. (Although, at least it doesn't break support for anything AFAICT)

Edit: Double checked and it appears /sys/class/power_supply/BAT0/ is a feature of the kernel since 2.6, so this should work for all modern linux distros.

I had originally added the support for OS X and I know this won't work there where the 'pmset -g batt' command would be the appropriate way to check this. Maybe some people that use some of the other supported environments can help us figure out if the method you used works for them. In theory I think we have full support for some other *nix like operating systems like BSD assuming they use a supported desktop environment... we might have to add some platform specific stuff to make this feature work for everyone.

boramalper commented 7 years ago

Thanks for your contribution, I think it's an interesting & useful one.

Just a few things:

  1. There should be a flag in config.py, as @jcmiller11 said.
  2. Instead of checking if "it exists", just try to handle possible exceptions by returning False.
  3. Why if status in [ "Discharging" ]: instead of if status == "Discharging"? :)

Looking forward to merge. :)

boramalper commented 7 years ago

Done in v2. :)