Browse Source

Prep v239: Add support for suspend-then-hibernate to loginctl.

tags/upstream/v239.1
Sven Eden 3 years ago
parent
commit
564def2927
4 changed files with 31 additions and 8 deletions
  1. +6
    -0
      cb/elogind.cbp
  2. +21
    -8
      src/login/eloginctl.c
  3. +1
    -0
      src/login/eloginctl.h
  4. +3
    -0
      src/login/loginctl.c

+ 6
- 0
cb/elogind.cbp View File

@@ -700,6 +700,10 @@
<Option target="all" />
<Option target="clean" />
</Unit>
<Unit filename="../src/login/70-power-switch.rules" />
<Unit filename="../src/login/70-uaccess.rules" />
<Unit filename="../src/login/71-seat.rules.in" />
<Unit filename="../src/login/73-seat-late.rules.in" />
<Unit filename="../src/login/eloginctl.c">
<Option compilerVar="CC" />
</Unit>
@@ -788,6 +792,8 @@
<Option target="all" />
<Option target="clean" />
</Unit>
<Unit filename="../src/login/org.freedesktop.login1.conf" />
<Unit filename="../src/login/org.freedesktop.login1.policy" />
<Unit filename="../src/login/pam_elogind.c">
<Option compilerVar="CC" />
</Unit>


+ 21
- 8
src/login/eloginctl.c View File

@@ -48,13 +48,14 @@ static const struct {
HandleAction action;
const char* verb;
} action_table[_ACTION_MAX] = {
[ACTION_HALT] = { HANDLE_HALT, "halt" },
[ACTION_POWEROFF] = { HANDLE_POWEROFF, "poweroff", },
[ACTION_REBOOT] = { HANDLE_REBOOT, "reboot", },
[ACTION_KEXEC] = { HANDLE_KEXEC, "kexec", },
[ACTION_SUSPEND] = { HANDLE_SUSPEND, "suspend", },
[ACTION_HIBERNATE] = { HANDLE_HIBERNATE, "hibernate", },
[ACTION_HYBRID_SLEEP] = { HANDLE_HYBRID_SLEEP, "hybrid-sleep" }
[ACTION_HALT] = { HANDLE_HALT, "halt" },
[ACTION_POWEROFF] = { HANDLE_POWEROFF, "poweroff", },
[ACTION_REBOOT] = { HANDLE_REBOOT, "reboot", },
[ACTION_KEXEC] = { HANDLE_KEXEC, "kexec", },
[ACTION_SUSPEND] = { HANDLE_SUSPEND, "suspend", },
[ACTION_HIBERNATE] = { HANDLE_HIBERNATE, "hibernate", },
[ACTION_HYBRID_SLEEP] = { HANDLE_HYBRID_SLEEP, "hybrid-sleep" },
[ACTION_SUSPEND_THEN_HIBERNATE] = { HANDLE_SUSPEND_THEN_HIBERNATE, "suspend-then-hibernate" }
/* ACTION_CANCEL_SHUTDOWN is handled differently */
};

@@ -262,6 +263,12 @@ static void elogind_log_special(enum elogind_action a) {
"MESSAGE_ID=" SD_MESSAGE_SLEEP_START_STR,
NULL);
break;
case ACTION_SUSPEND_THEN_HIBERNATE:
log_struct(LOG_INFO,
LOG_MESSAGE("Suspend-Then-Hibernate action called."),
"MESSAGE_ID=" SD_MESSAGE_SLEEP_START_STR,
NULL);
break;
case ACTION_CANCEL_SHUTDOWN:
log_struct(LOG_INFO,
LOG_MESSAGE("Cancel Shutdown called."),
@@ -322,6 +329,11 @@ static int elogind_reboot(sd_bus *bus, enum elogind_action a) {
description = "put system into hybrid sleep";
break;

case ACTION_SUSPEND_THEN_HIBERNATE:
method = "SuspendThenHibernate";
description = "put system into suspend followed by hibernate";
break;

default:
return -EINVAL;
}
@@ -570,7 +582,8 @@ int start_special(int argc, char *argv[], void *userdata) {
ACTION_REBOOT,
ACTION_SUSPEND,
ACTION_HIBERNATE,
ACTION_HYBRID_SLEEP)) {
ACTION_HYBRID_SLEEP,
ACTION_SUSPEND_THEN_HIBERNATE)) {
if (arg_when > 0)
return elogind_schedule_shutdown(bus, a);
else


+ 1
- 0
src/login/eloginctl.h View File

@@ -34,6 +34,7 @@ typedef enum elogind_action {
ACTION_SUSPEND,
ACTION_HIBERNATE,
ACTION_HYBRID_SLEEP,
ACTION_SUSPEND_THEN_HIBERNATE,
ACTION_CANCEL_SHUTDOWN,
_ACTION_MAX
} elogind_action;


+ 3
- 0
src/login/loginctl.c View File

@@ -1402,6 +1402,8 @@ static int help(int argc, char *argv[], void *userdata) {
" suspend Suspend the machine to memory\n"
" hibernate Suspend the machine to disk\n"
" hybrid-sleep Suspend the machine to memory and disk\n"
" suspend-then-hibernate Suspend the system, wake after a period of\n"
" time and put it into hibernate\n"
#endif // 0
, program_invocation_short_name);

@@ -1627,6 +1629,7 @@ static int loginctl_main(int argc, char *argv[], sd_bus *bus) {
{ "suspend", VERB_ANY, 1, 0, start_special },
{ "hibernate", VERB_ANY, 1, 0, start_special },
{ "hybrid-sleep", VERB_ANY, 1, 0, start_special },
{ "suspend-then-hibernate", VERB_ANY, 1, 0, start_special },
{ "cancel-shutdown", VERB_ANY, 1, 0, start_special },
#endif // 1
{}


Loading…
Cancel
Save