summaryrefslogtreecommitdiffstats
path: root/linux/Battery.h
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-01-23 03:08:21 -0200
committerHisham Muhammad <hisham@gobolinux.org>2015-01-23 03:08:21 -0200
commitc2108e5a482dfb8760849bb01264ed4bdb9f604f (patch)
tree29bd336760c5ca9cbebed5e4a1e007642064cbc4 /linux/Battery.h
parent3383d8e5561dfc6fb2b65e0a194df94ccb5e08af (diff)
Another mega-patch for the refactoring process.
Kinda runs, but functionality from the original main loop is still missing. Patience.
Diffstat (limited to 'linux/Battery.h')
-rw-r--r--linux/Battery.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/linux/Battery.h b/linux/Battery.h
index 88ba2b01..4cb22a89 100644
--- a/linux/Battery.h
+++ b/linux/Battery.h
@@ -15,10 +15,27 @@ Linux battery readings written by Ian P. Hands (iphands@gmail.com, ihands@redhat
#define _GNU_SOURCE
#endif
-ACPresence Battery_isOnAC();
+#define SYS_POWERSUPPLY_DIR "/sys/class/power_supply"
-double Battery_getProcBatData();
+// ----------------------------------------
+// READ FROM /proc
+// ----------------------------------------
-double Battery_getSysBatData();
+// This implementation reading from from /proc/acpi is really inefficient,
+// but I think this is on the way out so I did not rewrite it.
+// The /sys implementation below does things the right way.
+
+// ----------------------------------------
+// READ FROM /sys
+// ----------------------------------------
+
+/**
+ * Returns a pointer to the suffix of `str` if its beginning matches `prefix`.
+ * Returns NULL if the prefix does not match.
+ * Examples:
+ * match("hello world", "hello "); -> "world"
+ * match("hello world", "goodbye "); -> NULL
+ */
+void Battery_getData(double* level, ACPresence* isOnAC);
#endif