From 227aaf7e8a7b7c71a36d8312b879ee193f870c39 Mon Sep 17 00:00:00 2001 From: Raphael Graf Date: Wed, 5 Jun 2019 18:41:05 +0200 Subject: [PATCH] Add support for the battery widget on BSD systems (via upower) --- build/depends.py | 4 ++-- build/features.py | 2 +- src/util/battery/battery.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build/depends.py b/build/depends.py index 26018f195aa..34bad2e212c 100644 --- a/build/depends.py +++ b/build/depends.py @@ -120,9 +120,9 @@ def configure(self, build, conf): build.env.Append(LINKFLAGS='-framework IOKit') class UPower(Dependence): - """UPower is used to get battery measurements on Linux.""" + """UPower is used to get battery measurements on Linux and BSD.""" def configure(self, build, conf): - if not build.platform_is_linux: + if not build.platform_is_linux and not build.platform_is_bsd: return build.env.ParseConfig( 'pkg-config upower-glib --silence-errors --cflags --libs') diff --git a/build/features.py b/build/features.py index 6d19a62e3fb..4fcac6b71a8 100644 --- a/build/features.py +++ b/build/features.py @@ -1179,7 +1179,7 @@ def sources(self, build): return ["src/util/battery/batterywindows.cpp"] elif build.platform_is_osx: return ["src/util/battery/batterymac.cpp"] - elif build.platform_is_linux: + elif build.platform_is_linux or build.platform_is_bsd: return ["src/util/battery/batterylinux.cpp"] else: raise Exception('Battery support is not implemented for the target platform.') diff --git a/src/util/battery/battery.cpp b/src/util/battery/battery.cpp index e75d426565e..241bf85a31f 100644 --- a/src/util/battery/battery.cpp +++ b/src/util/battery/battery.cpp @@ -3,12 +3,12 @@ // Do not include platform-specific battery implementation unless we are built // with battery support (__BATTERY__). #ifdef __BATTERY__ -#ifdef Q_OS_LINUX -#include "util/battery/batterylinux.h" -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN) #include "util/battery/batterywindows.h" #elif defined(Q_OS_MAC) #include "util/battery/batterymac.h" +#else +#include "util/battery/batterylinux.h" #endif #endif #include "util/math.h" @@ -31,12 +31,12 @@ Battery::~Battery() { Battery* Battery::getBattery(QObject* parent) { #ifdef __BATTERY__ -#ifdef Q_OS_LINUX - return new BatteryLinux(parent); -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN) return new BatteryWindows(parent); #elif defined(Q_OS_MAC) return new BatteryMac(parent); +#else + return new BatteryLinux(parent); #endif #else Q_UNUSED(parent);