Commit Graph

183 Commits

Author SHA1 Message Date
e18939210b fix: lint 2026-02-24 00:00:57 +01:00
49d4049ea3 Fix SIGABRT on USB unplug race condition in battery module
Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com>
2026-02-23 22:55:05 +00:00
3bcadfdf5a battery: power switch events 2026-02-12 01:42:30 +03:00
bd222984bb fix: remove unnecessary console log for battery status 2026-02-11 01:12:21 +05:30
c3d29b1185 Merge branch 'master' into battery-plugging-instant-updates 2025-12-18 19:04:31 +01:00
ce1da5a178 Make udev_deleter not linux-only and fix freebsd build 2025-11-01 10:57:18 +01:00
4e25871655 Reapply "Make battery module update on plugging/unplugging again (refs #2519)"
This reverts commit bb2c67ebad.
2025-10-31 13:43:36 +01:00
ca62481dc9 fix: default weighted average to true 2025-10-26 06:44:53 +01:00
477f30705c Merge pull request #4208 from markx86/feat/battery-events
battery: Add support for battery level related events
2025-08-08 08:54:32 +02:00
310a473e65 enabled markup support for tooltip of battery and pulseaudio modules 2025-07-09 22:50:03 +05:30
10c116e54a Change default tooltip for the battery module. 2025-07-04 19:02:10 +02:00
53d8d3cd2a fix: Code formatting for clang-format/lint CI 2025-06-22 18:55:07 +02:00
08da7b5282 feat: Add support for battery related events 2025-06-22 17:45:12 +02:00
4be1f3bf42 fix: battery runtime estimation with negative sysfs values
Some drivers (example: qualcomm-battmgr, present on Snapdragon X1
laptops) expose the current_now and power_now values in sysfs as
negative int when the device is discharging, positive when charging.

This breaks the battery runtime estimation in Waybar, as it expects a
uint32 for power_now.

Change the battery module to use the absolute values of current_now and
power_now.
2025-02-16 18:33:03 +01:00
bb2c67ebad Revert "Make battery module update on plugging/unplugging again (refs #2519)" 2025-01-25 09:24:48 +01:00
f4608b3e31 Fix battery status changes not being detected
Historically we listened to /sys/class/poewr_supply inotify events,
which does not seem to work anymore.
We switched now to udev netlink kernel events.
2024-07-27 01:15:42 +02:00
d68bcbd292 modules/battery: Deprioritize capacity /sys value 2024-06-23 14:39:41 +01:00
a2c5a8215b style(battery): Capitalize float 'F' suffix 2024-04-24 15:07:26 +02:00
57197b8e01 feat(battery): Also support energy_full (instead of charge_full) 2024-04-24 14:57:11 +02:00
5c4e368819 style(battery): Indent level
It's now *inconsistent* in the file, but clang-tidy should be happy, sooo...
2024-04-24 09:05:11 +00:00
8d962430dd fix(battery): Remove duplicate line
This is what happens when you copy-paste from GitHub actions
2024-04-24 09:02:03 +00:00
54a85ea15f style: Apply clang-format change
At least I hope I copy-pased it correctly
2024-04-24 08:56:24 +00:00
efa7dc7ba4 fix(battery): Register health replacement for main format 2024-04-24 10:34:35 +02:00
8ef4ddd7ef fix: lint 2024-04-18 08:34:02 +02:00
67bf98a93e style: Change more var names to camelCase 2024-04-17 14:46:35 +02:00
3d54a6002d style: Remove superfluous 'const' on getInfo()
was here before, but is an easy fix for a clang-tidy warning
2024-04-13 13:19:54 +02:00
da47c94480 fix: Also use camelCase for usages of new vars 2024-04-13 13:18:50 +02:00
986b348bc7 style: Change new variables to camelCase 2024-04-13 13:11:14 +02:00
421ba6e31a fix: Add dummy information for battery cycles,health on FreeBSD 2024-04-12 18:48:54 +02:00
24690248db fix: Calculate battery health the right way around
I even did this originally, then got confused when my battery in particular showed 102% and, instead of checking the values I calculate with, just decided to do the stupid thing and do maths the wrong around
2024-04-11 02:40:04 +02:00
805faa47e6 style: Remove debug output
Oops
2024-04-10 18:48:03 +02:00
a59593fde1 feat(battery): Add {health} format replacement 2024-04-10 18:19:55 +02:00
7f1e623f77 style: Refactor battery cycle count choosing 2024-04-10 17:30:47 +02:00
43511992d9 feat(battery): Add {cycles} format replacement 2024-04-10 17:00:50 +02:00
fb6658e8fd chore: lint 2024-01-30 09:07:37 +01:00
d14a4a2b1a fixed early dereference error 2024-01-19 16:00:13 +05:30
dacffdb095 removed duplicate code 2024-01-19 15:27:11 +05:30
3390c16f52 added support for battery state-based classes on the entire waybar 2024-01-07 17:22:34 +05:30
1b98a04c93 chore: lint unrelated files so the CI passes 2023-10-02 12:33:28 -03:00
1ff4464b2f Use adapter status if battery status is inexistent 2023-09-10 15:16:43 -03:00
60611e9c2b Fix battery not showing for some devices
Adds 'bat-compatibility' boolean checking from configuration file.
2023-09-10 14:41:40 -03:00
6f66af9ab9 Merge pull request #2134 from bruceblore/battery-weighted-percentage
Display battery percentage as weighted average of battery levels
2023-09-04 22:01:40 +02:00
75eacb95ef Fix SEGFAULT in battery module
In waybar::modules::Battery::~Battery(), store a copy of the batteries_
iterator before calling erase(), as erase() invalidates the iterator.

Prior to this change, disconnecting outputs resulted in a SEGFAULT when
using the battery module; e.g.,

    [debug] Received SIGCHLD in signalThread
    [debug] Cmd exited with code 0
    [debug] Received SIGCHLD in signalThread
    [debug] Cmd exited with code 0
    [debug] Received SIGCHLD in signalThread
    [debug] Cmd exited with code 0
    [debug] Output removed: AU Optronics 0x2336
    [info] Bar configured (width: 1280, height: 25) for output: eDP-1
    [info] Bar configured (width: 1280, height: 25) for output: eDP-1
    zsh: segmentation fault (core dumped)  ./build/waybar -l trace

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
2023-05-22 10:16:30 -04:00
bad6cfae6f Added option to calculate battery percentage as total_energy * 100 / total_energy_full 2023-04-22 23:43:04 -07:00
ea17a66dfc fix: compilation errors with cpp_std=c++20
There were two main issues with fmtlib and C++20 mode:

 - `fmt::format` defaults to compile-time argument checking and requires
   using `fmt::runtime(format_string)` to bypass that.
 - `std::format` implementation introduces conflicting declarations and
   we have to specify the namespace for all `format`/`format_to` calls.
2023-01-20 22:50:02 -08:00
120cba0f5e fix: battery time remaining
time is reported in second and should be divided by 3600 and not 1000.
2023-01-13 09:44:39 +01:00
b5c686c0dd Merge pull request #1882 from LukashonakV/ISSUE#1877 2022-12-12 09:18:10 +01:00
a08967e008 Happy linter 2022-12-10 16:54:26 +03:00
2a76d8e5b9 Merge pull request #1862 from alebastr/battery-ignore-scope-device 2022-12-07 15:01:26 +01:00
b1833b1f36 feat: add macsmc-battery time remaining support for asahi
use time_to_empty_now and time_to_full_now
2022-12-05 22:09:05 +01:00