mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Add test if there is battery
This commit is contained in:
parent
45e44e03bd
commit
9d5f0e45c0
@ -6,7 +6,7 @@
|
||||
#include <filesystem>
|
||||
#endif
|
||||
#include <fmt/format.h>
|
||||
#if #defined(__linux__)
|
||||
#if defined(__linux__)
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
|
||||
|
@ -177,6 +177,17 @@ const std::tuple<uint8_t, float, std::string, float> waybar::modules::Battery::g
|
||||
uint32_t total_power = 0; // μW
|
||||
bool total_power_exists = false;
|
||||
#if defined(__FreeBSD__)
|
||||
/* Allocate state of battery units reported via ACPI. */
|
||||
int battery_units = 0;
|
||||
size_t battery_units_size = sizeof battery_units;
|
||||
if( sysctlbyname("hw.acpi.battery.units", &battery_units, &battery_units_size, NULL, 0) != 0) {
|
||||
throw std::runtime_error("sysctl hw.acpi.battery.units failed");
|
||||
}
|
||||
|
||||
if(battery_units < 0) {
|
||||
throw std::runtime_error("No battery units");
|
||||
}
|
||||
|
||||
int capacity;
|
||||
size_t size_capacity = sizeof capacity;
|
||||
if (sysctlbyname("hw.acpi.battery.life", &capacity, &size_capacity, NULL,0) != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user