src/login/org.freedesktop.login1.conf
dist_pkgsysconf_DATA += \
- src/login/elogind.conf
+ src/login/logind.conf
polkitpolicy_files += \
src/login/org.freedesktop.login1.policy
%.pc: %.pc.in
$(SED_PROCESS)
-%.conf: %.conf.in
- $(SED_PROCESS)
-
shell-completion/%: shell-completion/%.in
$(SED_PROCESS)
return r;
}
-static int do_sleep(const char *arg_verb) {
- _cleanup_strv_free_ char **modes = NULL, **states = NULL;
+static int do_sleep(const char *arg_verb, char **modes, char **states) {
char *arguments[] = {
NULL,
(char*) "pre",
return r;
}
-int shutdown_or_sleep(HandleAction action) {
+int shutdown_or_sleep(Manager *m, HandleAction action) {
+
+ assert(m);
+
switch (action) {
case HANDLE_POWEROFF:
return run_helper(HALT);
case HANDLE_KEXEC:
return run_helper(KEXEC);
case HANDLE_SUSPEND:
- return do_sleep("suspend");
+ return do_sleep("suspend", m->suspend_mode, m->suspend_state);
case HANDLE_HIBERNATE:
- return do_sleep("hibernate");
+ return do_sleep("hibernate", m->hibernate_mode, m->hibernate_state);
case HANDLE_HYBRID_SLEEP:
- return do_sleep("hybrid-sleep");
+ return do_sleep("hybrid-sleep", m->hybrid_sleep_mode, m->hybrid_sleep_state);
default:
return -EINVAL;
}
bool ignore_inhibited,
bool is_edge);
-int shutdown_or_sleep(HandleAction action);
+int shutdown_or_sleep(Manager *m, HandleAction action);
const char* handle_action_to_string(HandleAction h) _const_;
HandleAction handle_action_from_string(const char *s) _pure_;
&reply,
"ss", NULL, "replace-irreversibly");
#else
- r = shutdown_or_sleep(action);
+ r = shutdown_or_sleep(m, action);
#endif // 0
if (r < 0)
return r;
Login.IdleActionSec, config_parse_sec, 0, offsetof(Manager, idle_action_usec)
Login.RuntimeDirectorySize, config_parse_tmpfs_size, 0, offsetof(Manager, runtime_dir_size)
Login.RemoveIPC, config_parse_bool, 0, offsetof(Manager, remove_ipc)
+Sleep.SuspendMode, config_parse_strv, 0, offsetof(Manager, suspend_mode)
+Sleep.SuspendState, config_parse_strv, 0, offsetof(Manager, suspend_state)
+Sleep.HibernateMode, config_parse_strv, 0, offsetof(Manager, hibernate_mode)
+Sleep.HibernateState, config_parse_strv, 0, offsetof(Manager, hibernate_state)
+Sleep.HybridSleepMode, config_parse_strv, 0, offsetof(Manager, hybrid_sleep_mode)
+Sleep.HybridSleepState, config_parse_strv, 0, offsetof(Manager, hybrid_sleep_state)
if (r < 0)
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;
free(m->scheduled_shutdown_type);
free(m->scheduled_shutdown_tty);
free(m->wall_message);
+
+ 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);
}
}
static int manager_parse_config_file(Manager *m) {
+ const char *unit = NULL, *logind_conf, *sections;
+ FILE *file = NULL;
+ bool relaxed = false, allow_include = false, warn = true;
+
assert(m);
+/// elogind parses its own config file
+#if 0
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);
+#endif // 0
+
+ logind_conf = getenv("ELOGIND_CONF_FILE");
+ if (!logind_conf)
+ logind_conf = PKGSYSCONFDIR "/logind.conf";
+ sections = "Login\0Sleep\0";
+
+ 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[]) {
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
+
+[Sleep]
+#SuspendState=mem standby freeze
+#SuspendMode=
+#HibernateState=disk
+#HibernateMode=platform shutdown
+#HybridSleepState=disk
+#HybridSleepMode=suspend platform shutdown
bool remove_ipc;
+ char **suspend_state, **suspend_mode;
+ char **hibernate_state, **hibernate_mode;
+ char **hybrid_sleep_state, **hybrid_sleep_mode;
+
Hashmap *polkit_registry;
usec_t holdoff_timeout_usec;