brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.17k stars 615 forks source link

conky report error on BAT0 invalid path, but I didn't use BAT0 in config #675

Closed stardiviner closed 11 months ago

stardiviner commented 5 years ago

When I start conky from terminal , it reports error:

can't open /sys/class/power_supply/BAT0/uevent: No such file or directory
conky: can't open /proc/acpi/battery/BAT0/state: No such file or directory
conky: can't open /proc/apm: No such file or directory

But I didn't use BAT0 in my conky config file:

# Battery:  ${apcupsd_charge}
${voffset 140}
${offset 1250}${color1}${font DejaVu Sans Mono:size=8}Battery: ${color2}${battery BAT1}
${offset 1250}${color2}${font DejaVu Sans Mono:size=8}${battery_time BAT1}
${offset 1250}${color2}${font DejaVu Sans Mono:size=8}${battery_bar 6,100 BAT1} ${battery_percent BAT1}%

And I only have BAT1:

#+begin_src sh
ls /sys/class/power_supply/ | grep "BAT"
#+end_src

#+RESULTS[<2018-04-06 10:23:04> ffe9120fc7c9f4905f02fa416d150829ed2c0a76]:
: BAT1

In /sys/class/power_supply/BAT1. I got:

#+begin_src sh
ls /sys/class/power_supply/BAT1
#+end_src

#+RESULTS[<2018-04-06 10:23:39> b9ab96ea25cf3a1d6160c584edf2421d81016a38]:
#+begin_example
alarm
capacity
capacity_level
cycle_count
device
energy_full
energy_full_design
energy_now
manufacturer
model_name
power
power_now
present
serial_number
status
subsystem
technology
type
uevent
voltage_min_design
voltage_now
#+end_example
lasers commented 5 years ago

@stardiviner So I tried this on my computer (no battery). They all printed BAT1 for me. Maybe, we need more information or your config. What conky version? conky -V | head -n1.

conky: desktop window (25a) is root window
conky: window type - desktop
conky: drawing to created window (0x3800001)
conky: can't open /sys/class/power_supply/BAT1/uevent: No such file or directory
conky: can't open /proc/acpi/battery/BAT1/state: No such file or directory
conky: can't open /proc/apm: No such file or directory
conky: can't open /sys/class/power_supply/BAT1/uevent: No such file or directory
conky: can't open /proc/acpi/battery/BAT1/state: No such file or directory

Seems like most of them are in in core.cc.

src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:  END OBJ(battery_status, 0) obj->data.s = strndup(arg ? arg : "BAT0", text_buffer_size.get(*state));
src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:  END OBJ(battery_status, 0) obj->data.s = strndup(arg ? arg : "BAT0", text_buffer_size.get(*state));
src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:    strncpy(bat, "BAT0", 5);
src/core.cc:    strncpy(bat, "BAT0", 5);

But I wonder if it is because of update_interval_on_battery since this part seems hardcoded.

#endif /* BUILD_XSHAPE */

    last_update_time = 0.0;
    next_update_time = get_time() - fmod(get_time(), active_update_interval());
    info.looped = 0;
    while (terminate == 0
            && (total_run_times.get(*state) == 0 || info.looped < total_run_times.get(*state))) {
        if(update_interval_on_battery.get(*state) != NOBATTERY) {
            char buf[64];

            get_battery_short_status(buf, 64, "BAT0");
            on_battery = (buf[0] == 'D');
        }
        info.looped++;

Do you still get that message with default.conf? What about with update_interval_on_battery? Do you have that set? See if we can rule this one out or narrow down something somewhere.

stardiviner commented 5 years ago

My conky version: conky 1.11.0_pre This error does not appears with default config /usr/share/doc/conky-1.11.0_pre/conky.conf. With update_interval_on_batter added in the default config. I still get same error.

lasers commented 5 years ago

What caused BAT0 in your config? Was it update_interval_on_battery or one of the battery variables? If latter, does it happen with all of them or with one of the variables?

Also, see detect_battery. Maybe you need to add "BAT0,BAT1" or "BAT1"?

stardiviner commented 5 years ago

What caused BAT0 in your config? Was it update_interval_on_battery or one of the battery variables? If latter, does it happen with all of them or with one of the variables?

I only added one line update_interval_on_battery = 2 in default config /usr/share/doc/conky-1.11.0_pre/conky.conf. Then start conky with conky -c /usr/share/doc/conky-1.11.0_pre/conky.conf. Before adding that line, no this error. After adding that line, this error raised.

After adding line detect_battery = "BAT0,BAT1". Problem still persists. BTW, I indeed don't have that file. I even don't have /proc/acpi/battery/ path.

Tomunu commented 5 years ago

I was looking into this a little (no code yet). I didn't find the solution to the problem, but I found out some things.

On my system (running Arch Linux (5.1.7-arch1-1-ARCH)) I tried out the partial config from the original question. My laptop battery is numbered BAT0, so the BAT1 in the config causes conky errors, but none of them defaults to BAT0 (whether or not the update_interval_on_battery option is used).

Having the actual config files that display this problem (and the configs where the problem doesn't happen) might help.

stardiviner commented 4 years ago

I have detect_battery = "BAT0,BAT1", in my conky config. It should be detected. Also I have BAT0 explicitly specified in code like this ${battery BAT0}.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment, or this issue will be closed in 30 days.

github-actions[bot] commented 11 months ago

This issue was closed because it has been stalled for 30 days with no activity.