1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-25 23:21:33 +03:00

logind: add MESSAGE_IDs to interesting events

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2013-01-27 21:14:14 -05:00
parent 28dcf77ffe
commit c485437f50
2 changed files with 27 additions and 5 deletions

View File

@ -33,6 +33,7 @@
#include "logind-button.h"
#include "special.h"
#include "dbus-common.h"
#include "sd-messages.h"
Button* button_new(Manager *m, const char *name) {
Button *b;
@ -188,7 +189,10 @@ int button_process(Button *b) {
case KEY_POWER:
case KEY_POWER2:
log_info("Power key pressed.");
log_struct(LOG_INFO,
"MESSAGE=Power key pressed.",
MESSAGE_ID(SD_MESSAGE_POWER_KEY),
NULL);
return button_handle(b, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manager->power_key_ignore_inhibited, true);
/* The kernel is a bit confused here:
@ -198,11 +202,17 @@ int button_process(Button *b) {
*/
case KEY_SLEEP:
log_info("Suspend key pressed.");
log_struct(LOG_INFO,
"MESSAGE=Suspend key pressed.",
MESSAGE_ID(SD_MESSAGE_SUSPEND_KEY),
NULL);
return button_handle(b, INHIBIT_HANDLE_SUSPEND_KEY, b->manager->handle_suspend_key, b->manager->suspend_key_ignore_inhibited, true);
case KEY_SUSPEND:
log_info("Hibernate key pressed.");
log_struct(LOG_INFO,
"MESSAGE=Hibernate key pressed.",
MESSAGE_ID(SD_MESSAGE_HIBERNATE_KEY),
NULL);
return button_handle(b, INHIBIT_HANDLE_HIBERNATE_KEY, b->manager->handle_hibernate_key, b->manager->hibernate_key_ignore_inhibited, true);
}
@ -211,7 +221,10 @@ int button_process(Button *b) {
switch (ev.code) {
case SW_LID:
log_info("Lid closed.");
log_struct(LOG_INFO,
"MESSAGE=Lid closed.",
MESSAGE_ID(SD_MESSAGE_LID_CLOSED),
NULL);
b->lid_close_queued = true;
return button_handle(b, INHIBIT_HANDLE_LID_SWITCH, b->manager->handle_lid_switch, b->manager->lid_switch_ignore_inhibited, true);
@ -222,7 +235,10 @@ int button_process(Button *b) {
switch (ev.code) {
case SW_LID:
log_info("Lid opened.");
log_struct(LOG_INFO,
"MESSAGE=Lid opened.",
MESSAGE_ID(SD_MESSAGE_LID_OPENED),
NULL);
b->lid_close_queued = false;
break;
}

View File

@ -67,6 +67,12 @@ extern "C" {
#define SD_MESSAGE_OVERMOUNTING SD_ID128_MAKE(1d,ee,03,69,c7,fc,47,36,b7,09,9b,38,ec,b4,6e,e7)
#define SD_MESSAGE_LID_OPENED SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,6f)
#define SD_MESSAGE_LID_CLOSED SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,70)
#define SD_MESSAGE_POWER_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,71)
#define SD_MESSAGE_SUSPEND_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,72)
#define SD_MESSAGE_HIBERNATE_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,73)
#ifdef __cplusplus
}
#endif