diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-10-28 00:49:04 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-10-28 00:50:35 +0200 |
commit | 6524990fdc98370ecba5d9f73e67161e8798c010 (patch) | |
tree | 870ed57ed3c756dd34a0223692d1ec5b9e5ef44d /src/sleep/sleep.c | |
parent | 2001208c2ab631a69896d1f670c26846b70d1fb7 (diff) |
logind: support for hybrid sleep (i.e. suspend+hibernate at the same time)
Diffstat (limited to 'src/sleep/sleep.c')
-rw-r--r-- | src/sleep/sleep.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index 2f312675c5..218de3a567 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) { if (streq(argv[1], "suspend")) verb = "mem"; - else if (streq(argv[1], "hibernate")) + else if (streq(argv[1], "hibernate") || streq(argv[1], "hybrid-sleep")) verb = "disk"; else { log_error("Unknown action '%s'.", argv[1]); @@ -54,6 +54,16 @@ int main(int argc, char *argv[]) { goto finish; } + /* Configure the hibernation mode */ + if (streq(argv[1], "hibernate")) { + if (write_one_line_file("/sys/power/disk", "platform") < 0) + write_one_line_file("/sys/power/disk", "shutdown"); + } else if (streq(argv[1], "hybrid-sleep")) { + if (write_one_line_file("/sys/power/disk", "suspend") < 0) + if (write_one_line_file("/sys/power/disk", "platform") < 0) + write_one_line_file("/sys/power/disk", "shutdown"); + } + f = fopen("/sys/power/state", "we"); if (!f) { log_error("Failed to open /sys/power/state: %m"); @@ -73,12 +83,18 @@ int main(int argc, char *argv[]) { "MESSAGE=Suspending system...", "SLEEP=suspend", NULL); - else + else if (streq(argv[1], "hibernate")) log_struct(LOG_INFO, MESSAGE_ID(SD_MESSAGE_SLEEP_START), "MESSAGE=Hibernating system...", "SLEEP=hibernate", NULL); + else + log_struct(LOG_INFO, + MESSAGE_ID(SD_MESSAGE_SLEEP_START), + "MESSAGE=Hibernating and suspending system...", + "SLEEP=hybrid-sleep", + NULL); fputs(verb, f); fputc('\n', f); |