summaryrefslogtreecommitdiff
path: root/src/login/logind-action.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2015-08-23 14:54:39 +0200
committerSven Eden <yamakuzure@gmx.net>2017-03-14 10:15:07 +0100
commit24aa8c70860838af5c1dbfc81131888a4865d16c (patch)
tree7af29181ddb6c30bdac5afcea8f8d15dbde03ee0 /src/login/logind-action.c
parentd8a143df482f72fcbd408ffaef5c34aea6cdd655 (diff)
Handle suspend/hibernate/hybrid-suspend/shutdown/reboot directly
* configure.ac: Get paths of halt and reboot. * Makefile.am (systemsleepdir, systemshutdowndir): New variables. Look in them for hooks to run. * src/login/logind-action.c: Inline the salient bits from systemd's system-sleep.c here. * src/login/logind-dbus.c (execute_shutdown_or_sleep): Call our own shutdown_or_sleep helper instead of invoking a systemd method. * src/login/logind.h: Declare shutdown_or_sleep.
Diffstat (limited to 'src/login/logind-action.c')
-rw-r--r--src/login/logind-action.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/login/logind-action.c b/src/login/logind-action.c
index 16e1d9b59..7a57e1ba2 100644
--- a/src/login/logind-action.c
+++ b/src/login/logind-action.c
@@ -226,7 +226,8 @@ static int write_state(FILE **f, char **states) {
return r;
}
-static int do_sleep(const char *arg_verb, const char **modes, const char **states) {
+static int do_sleep(const char *arg_verb) {
+ _cleanup_strv_free_ char **modes = NULL, **states = NULL;
char *arguments[] = {
NULL,
(char*) "pre",
@@ -237,6 +238,10 @@ static int do_sleep(const char *arg_verb, const char **modes, const char **state
int r;
_cleanup_fclose_ FILE *f = NULL;
+ r = parse_sleep_config(arg_verb, &modes, &states);
+ if (r < 0)
+ return r;
+
/* This file is opened first, so that if we hit an error,
* we can abort before modifying any state. */
f = fopen("/sys/power/state", "we");
@@ -272,7 +277,7 @@ static int do_sleep(const char *arg_verb, const char **modes, const char **state
return r;
}
-int shutdown_or_sleep(Manager *m, HandleAction action) {
+int shutdown_or_sleep(HandleAction action) {
switch (action) {
case HANDLE_POWEROFF:
return run_helper(HALT);
@@ -283,11 +288,11 @@ int shutdown_or_sleep(Manager *m, HandleAction action) {
case HANDLE_KEXEC:
return run_helper(KEXEC);
case HANDLE_SUSPEND:
- return do_sleep("suspend", m->suspend_mode, m->suspend_state);
+ return do_sleep("suspend");
case HANDLE_HIBERNATE:
- return do_sleep("hibernate", m->hibernate_mode, m->hibernate_state);
+ return do_sleep("hibernate");
case HANDLE_HYBRID_SLEEP:
- return do_sleep("hybrid-sleep", m->hybrid_sleep_mode, m->hybrid_sleep_state);
+ return do_sleep("hybrid-sleep");
default:
return -EINVAL;
}