chiark / gitweb /
Incorporate sleep.conf into logind.conf
[elogind.git] / src / login / logind.c
index e89dc59b4b0e18c94aebbc26cfa6a33ded0f57ac..4cd320d8c199d6768e37ba108970601825e08bf2 100644 (file)
@@ -76,6 +76,23 @@ Manager *manager_new(void) {
         if (!m->kill_exclude_users)
                 goto fail;
 
+        m->suspend_mode = NULL;
+        m->suspend_state = strv_new("mem", "standby", "freeze", NULL);
+        if (!m->suspend_state)
+                goto fail;
+        m->hibernate_mode = strv_new("platform", "shutdown", NULL);
+        if (!m->hibernate_mode)
+                goto fail;
+        m->hibernate_state = strv_new("disk", NULL);
+        if (!m->hibernate_state)
+                goto fail;
+        m->hybrid_sleep_mode = strv_new("suspend", "platform", "shutdown", NULL);
+        if (!m->hybrid_sleep_mode)
+                goto fail;
+        m->hybrid_sleep_state = strv_new("disk", NULL);
+        if (!m->hybrid_sleep_state)
+                goto fail;
+
         m->udev = udev_new();
         if (!m->udev)
                 goto fail;
@@ -86,6 +103,7 @@ Manager *manager_new(void) {
 
         sd_event_set_watchdog(m->event, true);
 
+
         return m;
 
 fail:
@@ -161,7 +179,13 @@ void manager_free(Manager *m) {
         strv_free(m->kill_only_users);
         strv_free(m->kill_exclude_users);
 
-        free(m->action_job);
+        strv_free(m->suspend_mode);
+        strv_free(m->suspend_state);
+        strv_free(m->hibernate_mode);
+        strv_free(m->hibernate_state);
+        strv_free(m->hybrid_sleep_mode);
+        strv_free(m->hybrid_sleep_state);
+
         free(m);
 }
 
@@ -959,7 +983,7 @@ int manager_run(Manager *m) {
                 if (manager_dispatch_delayed(m) > 0)
                         continue;
 
-                if (m->action_what != 0 && !m->action_job) {
+                if (m->action_what != 0) {
                         usec_t x, y;
 
                         x = now(CLOCK_MONOTONIC);
@@ -975,13 +999,25 @@ int manager_run(Manager *m) {
 }
 
 static int manager_parse_config_file(Manager *m) {
+        const char *unit, *logind_conf, *sections;
+        FILE *file;
+        bool relaxed, allow_include, warn;
+
         assert(m);
 
-        return config_parse_many("/etc/systemd/logind.conf",
-                                 CONF_DIRS_NULSTR("systemd/logind.conf"),
-                                 "Login\0",
-                                 config_item_perf_lookup, logind_gperf_lookup,
-                                 false, m);
+        unit = NULL;
+        logind_conf = getenv("ELOGIND_CONF_FILE");
+        if (!logind_conf)
+                logind_conf = PKGSYSCONFDIR "/logind.conf";
+        sections = "Login\0Sleep\0";
+        file = NULL;
+        relaxed = false;
+        allow_include = false;
+        warn = true;
+
+        return config_parse(unit, logind_conf, file, sections,
+                            config_item_perf_lookup, logind_gperf_lookup,
+                            relaxed, allow_include, warn, m);
 }
 
 int main(int argc, char *argv[]) {