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

upower backend for battery widget WIP #266

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eylles
Copy link
Contributor

@eylles eylles commented May 24, 2021

this PR ain't complete, rather i opened it to get some feedback

since acpi can't detect the remaining time of battery for my laptop but upower can i decided to try and add the option to use upower as backend for the battery widget based on the watch widget recipe examples from https://awesomewm.org/recipes/watch/

i still have to clean stuff up and parse the information for the notification.

expected output from upower -i $(upower -e | grep BAT)

  native-path:          BAT0
  vendor:               Hewlett-Packard
  model:                Primary
  serial:               18267 2020/07/08
  power supply:         yes
  updated:              Mon 24 May 2021 03:47:30 PM CST (26 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              35.2621 Wh
    energy-empty:        0 Wh
    energy-full:         44.6754 Wh
    energy-full-design:  44.6754 Wh
    energy-rate:         22.7256 W
    voltage:             12.588 V
    time to full:        24.9 minutes
    percentage:          78%
    capacity:            100%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'

expected output from upower -i $(upower -e | grep BAT) | sed -n '/present/,/icon-name/p'

    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              35.2621 Wh
    energy-empty:        0 Wh
    energy-full:         44.6754 Wh
    energy-full-design:  44.6754 Wh
    energy-rate:         22.7256 W
    voltage:             12.588 V
    time to full:        24.9 minutes
    percentage:          78%
    capacity:            100%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'

from what i understand this widget can display information for more than one battery with acpi but i only have one battery on my laptop.

i will push some cleanups later.

anyway waiting for feedback 👍

@streetturtle
Copy link
Owner

This is awesome!
I think ideally the logic for processing the output of a command can be put in a separate file. But you can leave it as it is, and I can refactor it some time later.

@streetturtle streetturtle self-requested a review September 5, 2021 19:16
@eylles
Copy link
Contributor Author

eylles commented Dec 13, 2021

aaaaaand managed to add a notification with the upower backend, but couldn't parse the output of upower -i properly with lua so i gave up and used a "small" awk command since that was the only way i could figure out to do it.

image

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