summaryrefslogtreecommitdiff
path: root/src/ac-power.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ac-power.c')
-rw-r--r--src/ac-power.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ac-power.c b/src/ac-power.c
index a30216ffb3..24a68e717e 100644
--- a/src/ac-power.c
+++ b/src/ac-power.c
@@ -26,9 +26,8 @@
#include <libudev.h>
#include "util.h"
-#include "ac-power.h"
-int on_ac_power(void) {
+static int on_ac_power(void) {
int r;
struct udev *udev;
@@ -96,3 +95,17 @@ finish:
return r;
}
+
+int main(int argc, char *argv[]) {
+ int r;
+
+ /* This is mostly intended to be used for scripts which want
+ * to detect whether AC power is plugged in or not. */
+
+ if ((r = on_ac_power()) < 0) {
+ log_error("Failed to read AC status: %s", strerror(-r));
+ return EXIT_FAILURE;
+ }
+
+ return r == 0;
+}