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.
.zshrc)# Your configuration here
Spaceship version: echo $SPACESHIP_VERSION)
Zsh version:
Zsh framework:
Zsh plugin manager:
Terminal emulator:
Operating system:
Provide a screenshot that shows your issue.
Possible solution
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,
SPACESHIP_PROMPT_ORDER or SPACESHIP_BATTERY_SHOW variables.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.
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
https://github.com/matchai/spacefish/issues/96#issuecomment-431629359 - @matchai
https://github.com/matchai/spacefish/issues/96#issuecomment-432859694 - @Snuggle
We could prefer
acpibeforeupoweras suggested by @maximbaz and exit section if it's0?PRs welcome.