1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
From f8f9beb6a3bf81240d36bfec43e5db9b102ea91e Mon Sep 17 00:00:00 2001
From: Martin Pitt <martinpitt@gnome.org>
Date: Wed, 1 May 2013 10:55:49 -0700
Subject: [PATCH] Lock screen on suspend
Listen for logind's PrepareForSleep signal, and lock the screen (if configured
to do so). This mirrors what gnome-shell's screensaver does.
---
src/gs-listener-dbus.c | 28 ++++++++++++++++++++++++++++
src/gs-listener-dbus.h | 1 +
src/gs-monitor.c | 20 ++++++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
index 7f718fa..49586fd 100644
--- a/src/gs-listener-dbus.c
+++ b/src/gs-listener-dbus.c
@@ -871,6 +872,17 @@ listener_dbus_handle_system_message (DBusConnection *connection,
}
return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal (message, SYSTEMD_LOGIND_INTERFACE, "PrepareForSleep")) {
+ gboolean active;
+ if (dbus_message_get_args (message, NULL,
+ DBUS_TYPE_BOOLEAN, &active,
+ DBUS_TYPE_INVALID) && active) {
+ gs_debug ("systemd notified that system is about to sleep");
+ g_signal_emit (listener, signals [LOCK], 0, "");
+ } else {
+ gs_debug ("cannot parse PrepareForSleep");
+ }
+ return DBUS_HANDLER_RESULT_HANDLED;
} else if (dbus_message_is_signal (message, DBUS_INTERFACE_PROPERTIES, "PropertiesChanged")) {
if (_listener_message_path_is_our_session (listener, message)) {
@@ -1370,6 +1392,12 @@ gs_listener_acquire (GSListener *listener,
",interface='"DBUS_INTERFACE_PROPERTIES"'"
",member='PropertiesChanged'",
NULL);
+ dbus_bus_add_match (listener->priv->system_connection,
+ "type='signal'"
+ ",sender='"SYSTEMD_LOGIND_SERVICE"'"
+ ",interface='"SYSTEMD_LOGIND_INTERFACE"'"
+ ",member='PrepareForSleep'",
+ NULL);
return (res != -1);
}
--
1.8.1.2
|