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>
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.
Linux power_supply sysfs interface allows checking if the battery powers
the whole system or a specific device/tree of devices with `scope`
attribute[1]. We can use it to skip the non-system power supplies in the
battery module and avoid adding HIDs or other peripheral devices to the
total.
The logic is based on UPower, where it is assumed that "Unknown" devices
or devices without a `scope` are system power supplies.
[1]: https://lore.kernel.org/lkml/alpine.LNX.2.00.1201031556460.24984@pobox.suse.cz/T/
Mouse-over tooltips set on the label only appear once the mouse hovers
over exactly the label. Other apps (e.g. firefox) show the tooltip once
the pointer hovers the button. Not solely its label. With this commit we
get the same behaviour.
Fixes issue where the class parameters in style.css would have no
effect.
The CSS now references the GtkButton instead of the GtkLabel. Removing
all style-classes from the custom module GtkButton however removes
any properties set via style.css. Thus, the default classes 'flat' and
'text-button' are added on every update of these modules.
The AButton class is designed as full a substitute to ALabel. The
GtkButton attribute 'button_' is initialized with a label. This
label can the be referenced by the subsequent inheritors of AButton
instead of the GtkLabel attribute 'label_' of ALabel.
For convenience a GtkLabel* 'label_' attribute is added to AButton.
If the button cannot be clicked it is disabled, effectively acting
like its label predecessor.
GtkButton seems to catch one-click mouse events regardless of the
flags set on it. Therefore, 'signal_pressed' is connected to a
function creating a fake GdkEventButton* and calling 'handleToggle'
(for details on this possible bug in GTK see:
https://stackoverflow.com/questions/45334911 )
In accordance with other GtkButtons (i.e. the sway/workspace ones)
set_relief(Gtk::RELIEF_NONE) is called on the 'button_' instance.
1. battery.hpp - added local bool variable. Force to print warnings the
only once in order to warn user about wrong battery configuraion. And
does not bring a mess when the battery is turned off (gamepads, etc.)
2. dir_name is an object which takes a part in comparison. So converted to the string.
According to the [sysfs class power ABI],
/sys/class/power_supply/<supply_name>/status may contain "Not charging".
This is already handled by status_gt() and update() (where ' ' is
converted to '-' for use in config keys) but was not being read due to
skipws. Read with std::getline() to handle this case.
[sysfs class power ABI]: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-powerFixes: #1139
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
`format-discharging-full` has been impossible since #923 made it
impossible to be full and discharging at the same time. This should
fix that by only making `format-charging-full` impossible. Whether
or not that should be allowed is a good question, but beyond the
scope of this change.
Fixes#1031