vivien / i3blocks-contrib

Official repository for community contributed blocklets
https://github.com/vivien/i3blocks
Other
1.31k stars 486 forks source link

The blocklet battery-poly isn't working #448

Open bound-variable opened 2 years ago

bound-variable commented 2 years ago

Actual behavior

It doesn't appear in the bar.

i3blocks config relevant to blocklet(s)

(The default)

[battery-poly]
command=$SCRIPT_DIR/battery-poly
LABEL=BAT
interval=5

Output of blocklet(s) when run from command line

Traceback (most recent call last):
  File "/home/alan/.config/i3blocks/scripts/./battery-poly", line 170, in <module>
    main()
  File "/home/alan/.config/i3blocks/scripts/./battery-poly", line 166, in main
    print_status(get_configuration())
  File "/home/alan/.config/i3blocks/scripts/./battery-poly", line 81, in get_configuration
    get_current_charge(bat_name),
  File "/home/alan/.config/i3blocks/scripts/./battery-poly", line 112, in get_current_charge
    return int(Path(f"{PSEUDO_FS_PATH}{bat_name}/{CURRENT_CHARGE_FILENAME}").open().read().strip())
  File "/usr/lib/python3.10/pathlib.py", line 1117, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/power_supply/BAT0/energy_now'

Output of any relevant other commands that might help diagnostics

python 3.10.2-1 sysfsutils 2.1.1-1

schwukas commented 1 year ago

Not really the blocklet's fault. It just tries to read the file /sys/class/power_supply/BAT0/energy_now which doesn't seem to be available on your system. Not sure why.

Post the output of ls -la /sys/class/power_supply so I can try some debugging.

bound-variable commented 1 year ago

I don't run this anymore, but I don't mind following up.

Here's the output of the command you asked for:

total 0
drwxr-xr-x  2 root root 0 Mar 16 05:47 .
drwxr-xr-x 73 root root 0 Mar 16 05:47 ..
lrwxrwxrwx  1 root root 0 Mar 16 05:47 AC -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/AC
lrwxrwxrwx  1 root root 0 Mar 16 05:47 BAT0 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0

And inside of BAT0 I don't have energy_now, I have instead charge_now. My directory listings:

device
hwmon2
power
subsystem
alarm
capacity
capacity_level
charge_full
charge_full_design
charge_now
current_now
cycle_count
manufacturer
model_name
present
serial_number
status
technology
type
uevent
voltage_min_design
voltage_now

By the way, I personally use cat /sys/class/power_supply/BAT0/capacity to read my battery's charge level.