greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.87k stars 474 forks source link

battery block on Desktop triggers empty_format instead of missing_format #1862

Closed tarkh closed 1 year ago

tarkh commented 1 year ago

Hello! As title says, on my Desktop computer i3status-rust shows empty_format content instead of missing_format content. My system running on Arch Linux, battery block content:

[[block]]
block = "battery"
format = " $icon $percentage {$time |}"
full_format = " $icon $percentage "
device = "DisplayDevice"
driver = "upower"
missing_format = ""
empty_format = "test"
interval = 30

So with this config i3status-rust pannel shows red test word. If I remove empty_format from config at all, it shows red battery icon. Obviously, if I set empty_format to blank = "", it stops showing anything, but I think it's not right and missing_format should be triggered in the case of Desktop computer without any battery. Output of upower -d command:

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         no
  updated:              Tue 11 Apr 2023 10:00:03 PM MSK (154110 seconds ago)
  has history:          no
  has statistics:       no
  unknown
    warning-level:       none
    percentage:          0%
    icon-name:          'battery-missing-symbolic'

Daemon:
  daemon-version:  1.90.0
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  no
  critical-action: Hibernate

Am I missing something? Thanx in advance!

MaxVerevkin commented 1 year ago

With driver = "upower", the default "device" is DisplayDevice, which is always present. There are a few things you can do:

interval = 30

Unrelated, but this option does nothing with upower driver.

tarkh commented 1 year ago

@MaxVerevkin Thank you for reply! Well, I'm trying to create unified config for my devices, one of which is MacBook Pro 11.3 - with Arch Linux, i3status-rust and driver = "sysfs" I'm getting 110% at full charge. But with upower everything works fine with 100% at full charge on i3status-rust panel. So this config then migrated to Desktop. Just to add more details, on MacBook:

cat /sys/class/power_supply/BAT0/capacity
110

also shows 110 percents. Maybe it calculates from FULL_DESIGN and NOW values?:

cat /sys/class/power_supply/BAT0/uevent
...
POWER_SUPPLY_CHARGE_FULL_DESIGN=8880000
POWER_SUPPLY_CHARGE_FULL=9877000
POWER_SUPPLY_CHARGE_NOW=9624000
...

So in conclusion sysfs and upower handle battery status differently and in case of MacBook upower driver solves this issue. Maybe there is any advanced options in i3status-rust to solve this problem and keep sysfs module?

MaxVerevkin commented 1 year ago

Maybe there is any advanced options in i3status-rust to solve this problem and keep sysfs module?

No, but it might be worth investigating.

I'm trying to create unified config for my devices,

You can also use if_command = "..." to enable the block only on one of your devices.

tarkh commented 1 year ago

Thank you for your help! Ok, for now I just switched driver option on Desktop.