summaryrefslogtreecommitdiff
path: root/src/core/condition.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-12-25 16:29:51 +0100
committerLennart Poettering <lennart@poettering.net>2012-12-31 21:24:26 +0100
commit240dbaa44f8e5ad51775c776fc3ce9cd2f19f037 (patch)
tree607e02cd59aef350e3b32698742cd1e00bc71d7c /src/core/condition.c
parent3ec90c030081111900597ec5475d880893f10a76 (diff)
unit: add ConditionACPower=
Diffstat (limited to 'src/core/condition.c')
-rw-r--r--src/core/condition.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/condition.c b/src/core/condition.c
index 32a37ccad6..b3184922b8 100644
--- a/src/core/condition.c
+++ b/src/core/condition.c
@@ -221,6 +221,16 @@ static bool test_host(const char *parameter) {
return b;
}
+static bool test_ac_power(const char *parameter) {
+ int r;
+
+ r = parse_boolean(parameter);
+ if (r < 0)
+ return true;
+
+ return (on_ac_power() != 0) == !!r;
+}
+
bool condition_test(Condition *c) {
assert(c);
@@ -294,6 +304,9 @@ bool condition_test(Condition *c) {
case CONDITION_HOST:
return test_host(c->parameter) == !c->negate;
+ case CONDITION_AC_POWER:
+ return test_ac_power(c->parameter) == !c->negate;
+
case CONDITION_NULL:
return !c->negate;
@@ -364,6 +377,7 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
[CONDITION_VIRTUALIZATION] = "ConditionVirtualization",
[CONDITION_SECURITY] = "ConditionSecurity",
[CONDITION_HOST] = "ConditionHost",
+ [CONDITION_AC_POWER] = "ConditionACPower",
[CONDITION_NULL] = "ConditionNull"
};