summaryrefslogtreecommitdiff
path: root/src/login/logind.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2015-08-29 11:20:59 +0200
committerAndy Wingo <wingo@pobox.com>2015-08-29 11:25:06 +0200
commitcaa7531f137aeb260fbda53e89a22f516836e89b (patch)
tree221c1aab3b4fdd1aebfbcfe2c4802191a4fb6536 /src/login/logind.c
parentd6e877564a5b7f2758291825fa7a2becb663a630 (diff)
Incorporate sleep.conf into logind.conf
* src/login/logind-action.c (shutdown_or_sleep, do_sleep): Take modes from the manager instead of parsing them ourselves. * src/login/logind-dbus.c (execute_shutdown_or_sleep): Adapt to shutdown_or_sleep prototype change. * src/login/logind-gperf.gperf: Add config items from sleep.conf. * src/login/logind.c (manager_new): Wire up defaults for new config items. (manager_free): Free new config items. (manager_parse_config_file): Arrange to parse a single elogind/logind.conf file, not grovelling all over the filesystem. Take the file from the ELOGIND_CONF_FILE environment variable if present.
Diffstat (limited to 'src/login/logind.c')
-rw-r--r--src/login/logind.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/login/logind.c b/src/login/logind.c
index 5217e1a20..4cd320d8c 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -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,6 +179,13 @@ void manager_free(Manager *m) {
strv_free(m->kill_only_users);
strv_free(m->kill_exclude_users);
+ 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);
}
@@ -974,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[]) {