c58493c00a
Suspend to Hibernate is a new sleep method that invokes suspend for a predefined period of time before automatically waking up and hibernating the system. It's similar to HybridSleep however there isn't a performance impact on every suspend cycle. It's intended to use with systems that may have a higher power drain in their supported suspend states to prevent battery and data loss over an extended suspend cycle. Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
65 lines
2.6 KiB
C
65 lines
2.6 KiB
C
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
/***
|
|
This file is part of systemd.
|
|
|
|
Copyright 2012 Lennart Poettering
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
(at your option) any later version.
|
|
|
|
systemd is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
***/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "log.h"
|
|
#include "sleep-config.h"
|
|
#include "strv.h"
|
|
#include "util.h"
|
|
|
|
static void test_sleep(void) {
|
|
_cleanup_strv_free_ char
|
|
**standby = strv_new("standby", NULL),
|
|
**mem = strv_new("mem", NULL),
|
|
**disk = strv_new("disk", NULL),
|
|
**suspend = strv_new("suspend", NULL),
|
|
**reboot = strv_new("reboot", NULL),
|
|
**platform = strv_new("platform", NULL),
|
|
**shutdown = strv_new("shutdown", NULL),
|
|
**freez = strv_new("freeze", NULL);
|
|
|
|
log_info("Standby configured: %s", yes_no(can_sleep_state(standby) > 0));
|
|
log_info("Suspend configured: %s", yes_no(can_sleep_state(mem) > 0));
|
|
log_info("Hibernate configured: %s", yes_no(can_sleep_state(disk) > 0));
|
|
log_info("Hibernate+Suspend (Hybrid-Sleep) configured: %s", yes_no(can_sleep_disk(suspend) > 0));
|
|
log_info("Hibernate+Reboot configured: %s", yes_no(can_sleep_disk(reboot) > 0));
|
|
log_info("Hibernate+Platform configured: %s", yes_no(can_sleep_disk(platform) > 0));
|
|
log_info("Hibernate+Shutdown configured: %s", yes_no(can_sleep_disk(shutdown) > 0));
|
|
log_info("Freeze configured: %s", yes_no(can_sleep_state(freez) > 0));
|
|
|
|
log_info("Suspend configured and possible: %s", yes_no(can_sleep("suspend") > 0));
|
|
log_info("Hibernation configured and possible: %s", yes_no(can_sleep("hibernate") > 0));
|
|
log_info("Hybrid-sleep configured and possible: %s", yes_no(can_sleep("hybrid-sleep") > 0));
|
|
log_info("Suspend-to-Hibernate configured and possible: %s", yes_no(can_sleep("suspend-to-hibernate") > 0));
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
log_parse_environment();
|
|
log_open();
|
|
|
|
if (getuid() != 0)
|
|
log_warning("This program is unlikely to work for unprivileged users");
|
|
|
|
test_sleep();
|
|
|
|
return 0;
|
|
}
|