[gnome-battery-bench] Detect AC adapter on Apple hardware
- From: Christian Kellner <gicmo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-battery-bench] Detect AC adapter on Apple hardware
- Date: Mon, 13 Mar 2017 12:49:02 +0000 (UTC)
commit c7c2928368f3f00a1e3ef9938942858414c6c126
Author: Christian Kellner <gicmo gnome org>
Date: Fri Jan 13 15:46:11 2017 +0100
Detect AC adapter on Apple hardware
On Apple hardware the sysfs directory for the mains power supply
is called ADPx and not ACx.
https://bugzilla.gnome.org/show_bug.cgi?id=777149
src/power-monitor.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/power-monitor.c b/src/power-monitor.c
index 7a70f3c..e00e48b 100644
--- a/src/power-monitor.c
+++ b/src/power-monitor.c
@@ -216,6 +216,12 @@ adapter_free (Adapter *adapter)
}
static gboolean
+is_adapter(const char *name)
+{
+ return g_str_has_prefix(name, "AC") || g_str_has_prefix(name, "ADP");
+}
+
+static gboolean
find_power_supplies(GbbPowerMonitor *monitor,
GCancellable *cancellable,
GError **error)
@@ -246,7 +252,7 @@ find_power_supplies(GbbPowerMonitor *monitor,
const char *basename = g_file_info_get_name (info);
if (g_str_has_prefix (basename, "BAT"))
monitor->batteries = g_list_prepend (monitor->batteries, battery_new (child));
- else if (g_str_has_prefix (basename, "AC"))
+ else if (is_adapter (basename))
monitor->adapters = g_list_prepend (monitor->adapters, adapter_new (child));
next:
g_clear_object (&child);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]