1 |
ssuominen 14/06/02 16:39:34 |
2 |
|
3 |
Added: xfce4-session-4.10.1-systemd.patch |
4 |
Log: |
5 |
Use Fedora patch to introduce power management support using systemd to 4.10 series. Fix missing sys-power/pm-utils dependency in 4.11 (pre-4.12) series. |
6 |
|
7 |
(Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key 4868F14D) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 xfce-base/xfce4-session/files/xfce4-session-4.10.1-systemd.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/xfce-base/xfce4-session/files/xfce4-session-4.10.1-systemd.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/xfce-base/xfce4-session/files/xfce4-session-4.10.1-systemd.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: xfce4-session-4.10.1-systemd.patch |
16 |
=================================================================== |
17 |
http://pkgs.fedoraproject.org/cgit/xfce4-session.git/commit/xfce4-session-4.10.1-systemd.patch?id=9e8af8b3ee7e8e91817d087e80de29b1af6d4943 |
18 |
|
19 |
diff --git a/configure.ac b/configure.ac |
20 |
index 46ff366..8feee0b 100644 |
21 |
--- a/configure.ac |
22 |
+++ b/configure.ac |
23 |
@@ -98,7 +98,7 @@ XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.9.0]) |
24 |
|
25 |
dnl Check for polkit / systemd integration |
26 |
XDT_CHECK_OPTIONAL_PACKAGE([SYSTEMD], [polkit-gobject-1], [0.100], |
27 |
- [systemd], [Systemd support (through polit)]) |
28 |
+ [systemd], [Systemd support (through polkit)]) |
29 |
|
30 |
dnl Check for debugging support |
31 |
XDT_FEATURE_DEBUG([xfsm_debug_default]) |
32 |
@@ -202,10 +202,10 @@ echo " * Legacy session management: yes" |
33 |
else |
34 |
echo " * Legacy session management: no" |
35 |
fi |
36 |
-if test x"$GNOME_KEYRING_FOUND" = x"yes"; then |
37 |
-echo " * Gnome Keyring support: yes" |
38 |
+if test x"$SYSTEMD_FOUND" = x"yes"; then |
39 |
+echo " * Systemd support (through polkit): yes" |
40 |
else |
41 |
-echo " * Gnome Keyring support: no" |
42 |
+echo " * Systemd support (through polkit): no" |
43 |
fi |
44 |
|
45 |
echo |
46 |
diff --git a/xfce4-session/Makefile.am b/xfce4-session/Makefile.am |
47 |
index 5472b33..ea706fd 100644 |
48 |
--- a/xfce4-session/Makefile.am |
49 |
+++ b/xfce4-session/Makefile.am |
50 |
@@ -38,6 +38,8 @@ xfce4_session_SOURCES = \ |
51 |
xfsm-compat-gnome.h \ |
52 |
xfsm-compat-kde.c \ |
53 |
xfsm-compat-kde.h \ |
54 |
+ xfsm-consolekit.c \ |
55 |
+ xfsm-consolekit.h \ |
56 |
xfsm-dns.c \ |
57 |
xfsm-dns.h \ |
58 |
xfsm-error.c \ |
59 |
@@ -67,10 +69,6 @@ if HAVE_SYSTEMD |
60 |
xfce4_session_SOURCES += \ |
61 |
xfsm-systemd.c \ |
62 |
xfsm-systemd.h |
63 |
-else |
64 |
-xfce4_session_SOURCES += \ |
65 |
- xfsm-consolekit.c \ |
66 |
- xfsm-consolekit.h |
67 |
endif |
68 |
|
69 |
xfce4_session_CFLAGS = \ |
70 |
diff --git a/xfce4-session/xfsm-shutdown.c b/xfce4-session/xfsm-shutdown.c |
71 |
index 4c483a7..329c4f6 100644 |
72 |
--- a/xfce4-session/xfsm-shutdown.c |
73 |
+++ b/xfce4-session/xfsm-shutdown.c |
74 |
@@ -63,6 +63,7 @@ |
75 |
#include <xfce4-session/xfsm-shutdown.h> |
76 |
#include <xfce4-session/xfsm-compat-gnome.h> |
77 |
#include <xfce4-session/xfsm-compat-kde.h> |
78 |
+#include <xfce4-session/xfsm-consolekit.h> |
79 |
#include <xfce4-session/xfsm-fadeout.h> |
80 |
#include <xfce4-session/xfsm-global.h> |
81 |
#include <xfce4-session/xfsm-legacy.h> |
82 |
@@ -70,8 +71,6 @@ |
83 |
|
84 |
#ifdef HAVE_SYSTEMD |
85 |
#include <xfce4-session/xfsm-systemd.h> |
86 |
-#else |
87 |
-#include <xfce4-session/xfsm-consolekit.h> |
88 |
#endif |
89 |
|
90 |
static void xfsm_shutdown_finalize (GObject *object); |
91 |
@@ -98,9 +97,8 @@ struct _XfsmShutdown |
92 |
|
93 |
#ifdef HAVE_SYSTEMD |
94 |
XfsmSystemd *systemd; |
95 |
-#else |
96 |
- XfsmConsolekit *consolekit; |
97 |
#endif |
98 |
+ XfsmConsolekit *consolekit; |
99 |
XfsmUPower *upower; |
100 |
|
101 |
/* kiosk settings */ |
102 |
@@ -139,10 +137,14 @@ xfsm_shutdown_init (XfsmShutdown *shutdown) |
103 |
XfceKiosk *kiosk; |
104 |
|
105 |
#ifdef HAVE_SYSTEMD |
106 |
- shutdown->systemd = xfsm_systemd_get (); |
107 |
-#else |
108 |
- shutdown->consolekit = xfsm_consolekit_get (); |
109 |
+ shutdown->consolekit = NULL; |
110 |
+ shutdown->systemd = NULL; |
111 |
+ if (LOGIND_RUNNING()) |
112 |
+ shutdown->systemd = xfsm_systemd_get (); |
113 |
+ else |
114 |
#endif |
115 |
+ shutdown->consolekit = xfsm_consolekit_get (); |
116 |
+ |
117 |
shutdown->upower = xfsm_upower_get (); |
118 |
shutdown->helper_state = SUDO_NOT_INITIAZED; |
119 |
shutdown->helper_require_password = FALSE; |
120 |
@@ -162,10 +164,11 @@ xfsm_shutdown_finalize (GObject *object) |
121 |
XfsmShutdown *shutdown = XFSM_SHUTDOWN (object); |
122 |
|
123 |
#ifdef HAVE_SYSTEMD |
124 |
- g_object_unref (G_OBJECT (shutdown->systemd)); |
125 |
-#else |
126 |
- g_object_unref (G_OBJECT (shutdown->consolekit)); |
127 |
+ if (shutdown->systemd != NULL) |
128 |
+ g_object_unref (G_OBJECT (shutdown->systemd)); |
129 |
#endif |
130 |
+ if (shutdown->consolekit != NULL) |
131 |
+ g_object_unref (G_OBJECT (shutdown->consolekit)); |
132 |
g_object_unref (G_OBJECT (shutdown->upower)); |
133 |
|
134 |
/* close down helper */ |
135 |
@@ -657,10 +660,11 @@ xfsm_shutdown_try_restart (XfsmShutdown *shutdown, |
136 |
return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_RESTART, error); |
137 |
else |
138 |
#ifdef HAVE_SYSTEMD |
139 |
- return xfsm_systemd_try_restart (shutdown->systemd, error); |
140 |
-#else |
141 |
- return xfsm_consolekit_try_restart (shutdown->consolekit, error); |
142 |
+ if (shutdown->systemd != NULL) |
143 |
+ return xfsm_systemd_try_restart (shutdown->systemd, error); |
144 |
+ else |
145 |
#endif |
146 |
+ return xfsm_consolekit_try_restart (shutdown->consolekit, error); |
147 |
} |
148 |
|
149 |
|
150 |
@@ -678,10 +682,11 @@ xfsm_shutdown_try_shutdown (XfsmShutdown *shutdown, |
151 |
return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_SHUTDOWN, error); |
152 |
else |
153 |
#ifdef HAVE_SYSTEMD |
154 |
- return xfsm_systemd_try_shutdown (shutdown->systemd, error); |
155 |
-#else |
156 |
- return xfsm_consolekit_try_shutdown (shutdown->consolekit, error); |
157 |
+ if (shutdown->systemd != NULL) |
158 |
+ return xfsm_systemd_try_shutdown (shutdown->systemd, error); |
159 |
+ else |
160 |
#endif |
161 |
+ return xfsm_consolekit_try_shutdown (shutdown->consolekit, error); |
162 |
} |
163 |
|
164 |
|
165 |
@@ -692,6 +697,11 @@ xfsm_shutdown_try_suspend (XfsmShutdown *shutdown, |
166 |
{ |
167 |
g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); |
168 |
|
169 |
+#ifdef HAVE_SYSTEMD |
170 |
+ if (shutdown->systemd != NULL) |
171 |
+ return xfsm_systemd_try_suspend (shutdown->systemd, error); |
172 |
+ else |
173 |
+#endif |
174 |
return xfsm_upower_try_suspend (shutdown->upower, error); |
175 |
} |
176 |
|
177 |
@@ -703,6 +713,11 @@ xfsm_shutdown_try_hibernate (XfsmShutdown *shutdown, |
178 |
{ |
179 |
g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); |
180 |
|
181 |
+#ifdef HAVE_SYSTEMD |
182 |
+ if (shutdown->systemd != NULL) |
183 |
+ return xfsm_systemd_try_hibernate (shutdown->systemd, error); |
184 |
+ else |
185 |
+#endif |
186 |
return xfsm_upower_try_hibernate (shutdown->upower, error); |
187 |
} |
188 |
|
189 |
@@ -722,10 +737,14 @@ xfsm_shutdown_can_restart (XfsmShutdown *shutdown, |
190 |
} |
191 |
|
192 |
#ifdef HAVE_SYSTEMD |
193 |
- if (xfsm_systemd_can_restart (shutdown->systemd, can_restart, error)) |
194 |
-#else |
195 |
- if (xfsm_consolekit_can_restart (shutdown->consolekit, can_restart, error)) |
196 |
+ if (shutdown->systemd != NULL) |
197 |
+ { |
198 |
+ if (xfsm_systemd_can_restart (shutdown->systemd, can_restart, error)) |
199 |
+ return TRUE; |
200 |
+ } |
201 |
+ else |
202 |
#endif |
203 |
+ if (xfsm_consolekit_can_restart (shutdown->consolekit, can_restart, error)) |
204 |
return TRUE; |
205 |
|
206 |
if (xfsm_shutdown_sudo_init (shutdown, error)) |
207 |
@@ -753,10 +772,14 @@ xfsm_shutdown_can_shutdown (XfsmShutdown *shutdown, |
208 |
} |
209 |
|
210 |
#ifdef HAVE_SYSTEMD |
211 |
- if (xfsm_systemd_can_shutdown (shutdown->systemd, can_shutdown, error)) |
212 |
-#else |
213 |
- if (xfsm_consolekit_can_shutdown (shutdown->consolekit, can_shutdown, error)) |
214 |
+ if (shutdown->systemd != NULL) |
215 |
+ { |
216 |
+ if (xfsm_systemd_can_shutdown (shutdown->systemd, can_shutdown, error)) |
217 |
+ return TRUE; |
218 |
+ } |
219 |
+ else |
220 |
#endif |
221 |
+ if (xfsm_consolekit_can_shutdown (shutdown->consolekit, can_shutdown, error)) |
222 |
return TRUE; |
223 |
|
224 |
if (xfsm_shutdown_sudo_init (shutdown, error)) |
225 |
@@ -784,6 +807,12 @@ xfsm_shutdown_can_suspend (XfsmShutdown *shutdown, |
226 |
return TRUE; |
227 |
} |
228 |
|
229 |
+#ifdef HAVE_SYSTEMD |
230 |
+ if (shutdown->systemd != NULL) |
231 |
+ return xfsm_systemd_can_suspend (shutdown->systemd, can_suspend, |
232 |
+ auth_suspend, error); |
233 |
+ else |
234 |
+#endif |
235 |
return xfsm_upower_can_suspend (shutdown->upower, can_suspend, |
236 |
auth_suspend, error); |
237 |
} |
238 |
@@ -804,6 +833,12 @@ xfsm_shutdown_can_hibernate (XfsmShutdown *shutdown, |
239 |
return TRUE; |
240 |
} |
241 |
|
242 |
+#ifdef HAVE_SYSTEMD |
243 |
+ if (shutdown->systemd != NULL) |
244 |
+ return xfsm_systemd_can_hibernate (shutdown->systemd, can_hibernate, |
245 |
+ auth_hibernate, error); |
246 |
+ else |
247 |
+#endif |
248 |
return xfsm_upower_can_hibernate (shutdown->upower, can_hibernate, |
249 |
auth_hibernate, error); |
250 |
} |
251 |
diff --git a/xfce4-session/xfsm-systemd.c b/xfce4-session/xfsm-systemd.c |
252 |
index 7bdd39d..f18fbf7 100644 |
253 |
--- a/xfce4-session/xfsm-systemd.c |
254 |
+++ b/xfce4-session/xfsm-systemd.c |
255 |
@@ -24,6 +24,7 @@ |
256 |
#include <dbus/dbus-glib.h> |
257 |
#include <dbus/dbus-glib-lowlevel.h> |
258 |
|
259 |
+#include <libxfsm/xfsm-util.h> |
260 |
#include <xfce4-session/xfsm-systemd.h> |
261 |
|
262 |
|
263 |
@@ -33,8 +34,12 @@ |
264 |
#define SYSTEMD_DBUS_INTERFACE "org.freedesktop.login1.Manager" |
265 |
#define SYSTEMD_REBOOT_ACTION "Reboot" |
266 |
#define SYSTEMD_POWEROFF_ACTION "PowerOff" |
267 |
+#define SYSTEMD_SUSPEND_ACTION "Suspend" |
268 |
+#define SYSTEMD_HIBERNATE_ACTION "Hibernate" |
269 |
#define SYSTEMD_REBOOT_TEST "org.freedesktop.login1.reboot" |
270 |
#define SYSTEMD_POWEROFF_TEST "org.freedesktop.login1.power-off" |
271 |
+#define SYSTEMD_SUSPEND_TEST "org.freedesktop.login1.suspend" |
272 |
+#define SYSTEMD_HIBERNATE_TEST "org.freedesktop.login1.hibernate" |
273 |
|
274 |
|
275 |
|
276 |
@@ -93,6 +98,22 @@ xfsm_systemd_finalize (GObject *object) |
277 |
} |
278 |
|
279 |
|
280 |
+ |
281 |
+static gboolean |
282 |
+xfsm_systemd_lock_screen (GError **error) |
283 |
+{ |
284 |
+ XfconfChannel *channel; |
285 |
+ gboolean ret = TRUE; |
286 |
+ |
287 |
+ channel = xfsm_open_config (); |
288 |
+ if (xfconf_channel_get_bool (channel, "/shutdown/LockScreen", FALSE)) |
289 |
+ ret = g_spawn_command_line_async ("xflock4", error); |
290 |
+ |
291 |
+ return ret; |
292 |
+} |
293 |
+ |
294 |
+ |
295 |
+ |
296 |
static gboolean |
297 |
xfsm_systemd_can_method (XfsmSystemd *systemd, |
298 |
gboolean *can_method, |
299 |
@@ -205,6 +226,34 @@ xfsm_systemd_try_shutdown (XfsmSystemd *systemd, |
300 |
|
301 |
|
302 |
gboolean |
303 |
+xfsm_systemd_try_suspend (XfsmSystemd *systemd, |
304 |
+ GError **error) |
305 |
+{ |
306 |
+ if (!xfsm_systemd_lock_screen (error)) |
307 |
+ return FALSE; |
308 |
+ |
309 |
+ return xfsm_systemd_try_method (systemd, |
310 |
+ SYSTEMD_SUSPEND_ACTION, |
311 |
+ error); |
312 |
+} |
313 |
+ |
314 |
+ |
315 |
+ |
316 |
+gboolean |
317 |
+xfsm_systemd_try_hibernate (XfsmSystemd *systemd, |
318 |
+ GError **error) |
319 |
+{ |
320 |
+ if (!xfsm_systemd_lock_screen (error)) |
321 |
+ return FALSE; |
322 |
+ |
323 |
+ return xfsm_systemd_try_method (systemd, |
324 |
+ SYSTEMD_HIBERNATE_ACTION, |
325 |
+ error); |
326 |
+} |
327 |
+ |
328 |
+ |
329 |
+ |
330 |
+gboolean |
331 |
xfsm_systemd_can_restart (XfsmSystemd *systemd, |
332 |
gboolean *can_restart, |
333 |
GError **error) |
334 |
@@ -227,3 +276,39 @@ xfsm_systemd_can_shutdown (XfsmSystemd *systemd, |
335 |
SYSTEMD_POWEROFF_TEST, |
336 |
error); |
337 |
} |
338 |
+ |
339 |
+ |
340 |
+ |
341 |
+gboolean |
342 |
+xfsm_systemd_can_suspend (XfsmSystemd *systemd, |
343 |
+ gboolean *can_suspend, |
344 |
+ gboolean *auth_suspend, |
345 |
+ GError **error) |
346 |
+{ |
347 |
+ gboolean ret = FALSE; |
348 |
+ |
349 |
+ ret = xfsm_systemd_can_method (systemd, |
350 |
+ can_suspend, |
351 |
+ SYSTEMD_SUSPEND_TEST, |
352 |
+ error); |
353 |
+ *auth_suspend = *can_suspend; |
354 |
+ return ret; |
355 |
+} |
356 |
+ |
357 |
+ |
358 |
+ |
359 |
+gboolean |
360 |
+xfsm_systemd_can_hibernate (XfsmSystemd *systemd, |
361 |
+ gboolean *can_hibernate, |
362 |
+ gboolean *auth_hibernate, |
363 |
+ GError **error) |
364 |
+{ |
365 |
+ gboolean ret = FALSE; |
366 |
+ |
367 |
+ ret = xfsm_systemd_can_method (systemd, |
368 |
+ can_hibernate, |
369 |
+ SYSTEMD_HIBERNATE_TEST, |
370 |
+ error); |
371 |
+ *auth_hibernate = *can_hibernate; |
372 |
+ return ret; |
373 |
+} |
374 |
diff --git a/xfce4-session/xfsm-systemd.h b/xfce4-session/xfsm-systemd.h |
375 |
index 8223622..c5e74b5 100644 |
376 |
--- a/xfce4-session/xfsm-systemd.h |
377 |
+++ b/xfce4-session/xfsm-systemd.h |
378 |
@@ -22,6 +22,8 @@ |
379 |
#ifndef __XFSM_SYSTEMD_H__ |
380 |
#define __XFSM_SYSTEMD_H__ |
381 |
|
382 |
+#define LOGIND_RUNNING() (access ("/run/systemd/seats/", F_OK) >= 0) |
383 |
+ |
384 |
typedef struct _XfsmSystemdClass XfsmSystemdClass; |
385 |
typedef struct _XfsmSystemd XfsmSystemd; |
386 |
|
387 |
@@ -42,6 +44,12 @@ gboolean xfsm_systemd_try_restart (XfsmSystemd *systemd, |
388 |
gboolean xfsm_systemd_try_shutdown (XfsmSystemd *systemd, |
389 |
GError **error); |
390 |
|
391 |
+gboolean xfsm_systemd_try_suspend (XfsmSystemd *systemd, |
392 |
+ GError **error); |
393 |
+ |
394 |
+gboolean xfsm_systemd_try_hibernate (XfsmSystemd *systemd, |
395 |
+ GError **error); |
396 |
+ |
397 |
gboolean xfsm_systemd_can_restart (XfsmSystemd *systemd, |
398 |
gboolean *can_restart, |
399 |
GError **error); |
400 |
@@ -50,6 +58,16 @@ gboolean xfsm_systemd_can_shutdown (XfsmSystemd *systemd, |
401 |
gboolean *can_shutdown, |
402 |
GError **error); |
403 |
|
404 |
+gboolean xfsm_systemd_can_suspend (XfsmSystemd *systemd, |
405 |
+ gboolean *can_suspend, |
406 |
+ gboolean *auth_suspend, |
407 |
+ GError **error); |
408 |
+ |
409 |
+gboolean xfsm_systemd_can_hibernate (XfsmSystemd *systemd, |
410 |
+ gboolean *can_hibernate, |
411 |
+ gboolean *auth_hibernate, |
412 |
+ GError **error); |
413 |
+ |
414 |
G_END_DECLS |
415 |
|
416 |
#endif /* __XFSM_SYSTEMD_H__ */ |