Spaceship-prompt: Battery percentage is shown for a peripheral device.

Created on 10 Oct 2018  Â·  7Comments  Â·  Source: denysdovhan/spaceship-prompt

Current behavior

My prompt was always showing "0%" for the battery level, even though I'm on a desktop that doesn't have a battery. It turns out that this is because I recently started using a Wacom tablet, which always shows a battery level of "0%", despite the fact that it doesn't have a battery.

Here's the output of running upower on my machine, which is what battery.zsh is using to query for battery information.

$ upower -e
/org/freedesktop/UPower/devices/tablet_wacom_battery_0
/org/freedesktop/UPower/devices/DisplayDevice
$ upower -i /org/freedesktop/UPower/devices/tablet_wacom_battery_0
  native-path:          wacom_battery_0
  model:                Wacom Intuos S
  power supply:         no
  updated:              Wed 10 Oct 2018 11:01:39 AM EDT (39 seconds ago)
  has history:          yes
  has statistics:       yes
  tablet
    warning-level:       none
    percentage:          0%
    icon-name:          'battery-missing-symbolic'

Expected behavior

Battery level should be shown only for the machine, and not for any peripheral devices.

Relevant Zsh configuration (.zshrc)

# Your configuration here

Environment

Spaceship version: (use echo $SPACESHIP_VERSION)
Zsh version:
Zsh framework:
Zsh plugin manager:
Terminal emulator:
Operating system:

Screenshot

Provide a screenshot that shows your issue.

screenshot

Possible solution

bug help-wanted

Most helpful comment

There was similar issue reported with spacefish, fish shell port of spaceship. Sharing some bits of discussions from there.

https://github.com/matchai/spacefish/issues/96#issuecomment-431628729 - @Snuggle

Is it... Trying to use the battery for my wireless mouse? I use the Logitech MX Master.

https://github.com/matchai/spacefish/issues/96#issuecomment-431629359 - @matchai

create a whitelist of relevant device batteries prefixes (mouse_ should definitely be filtered out).

https://github.com/matchai/spacefish/issues/96#issuecomment-432859694 - @Snuggle

detect if battery level is >0%? Not the best solution but... It works for the most part.

~
➜ acpi -b
Battery 0: Discharging, 0%, rate information unavailable

We could prefer acpi before upower as suggested by @maximbaz and exit section if it's 0 ?

PRs welcome.

All 7 comments

Can you check what other methods of querying battery level output for you?

pmset -g batt
acpi -b

I get command not found for both.

These are tools that you'd have to install if you want to try, I asked this because I doubt we can do anything about upower discovering more batteries than needed, but if either pmset or acpi tools behave better, we can make battery module prefer these tools over upower.

Ah, that's what you meant. I installed acpi and acpi -b gives me nothing. I'm on Debian and pmset seems to be a Mac utility, so nothing for that. What you suggest sounds good to me.

Thanks for the detailed report. I see the following options,

  • Detect removable devices which provide battery information and filter them out. But this might lead to never ending list of devices or we could use generic filters like tablet etc,.
  • Similar to #233, provide option to specify the battery to be used on prompt.
  • Disable battery section from the user end with either SPACESHIP_PROMPT_ORDER or SPACESHIP_BATTERY_SHOW variables.
  • As @maximbaz noted, If any of the other tools behave better, prefer those.

I propose moving acpi before upower, simple and seems like what we need.

There was similar issue reported with spacefish, fish shell port of spaceship. Sharing some bits of discussions from there.

https://github.com/matchai/spacefish/issues/96#issuecomment-431628729 - @Snuggle

Is it... Trying to use the battery for my wireless mouse? I use the Logitech MX Master.

https://github.com/matchai/spacefish/issues/96#issuecomment-431629359 - @matchai

create a whitelist of relevant device batteries prefixes (mouse_ should definitely be filtered out).

https://github.com/matchai/spacefish/issues/96#issuecomment-432859694 - @Snuggle

detect if battery level is >0%? Not the best solution but... It works for the most part.

~
➜ acpi -b
Battery 0: Discharging, 0%, rate information unavailable

We could prefer acpi before upower as suggested by @maximbaz and exit section if it's 0 ?

PRs welcome.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doole picture doole  Â·  4Comments

MatthiasJ picture MatthiasJ  Â·  4Comments

salmanulfarzy picture salmanulfarzy  Â·  3Comments

Vvkmnn picture Vvkmnn  Â·  3Comments

nfischer picture nfischer  Â·  3Comments