1 |
ssuominen 14/05/31 19:19:58 |
2 |
|
3 |
Added: xfce4-session-4.11.0-upower-0.99.patch |
4 |
Log: |
5 |
Restrict 4.10 series and -r0 of 4.11.0 to old UPower and add -r1 for compability with UPower >= 0.99 |
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.11.0-upower-0.99.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/xfce-base/xfce4-session/files/xfce4-session-4.11.0-upower-0.99.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/xfce-base/xfce4-session/files/xfce4-session-4.11.0-upower-0.99.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: xfce4-session-4.11.0-upower-0.99.patch |
16 |
=================================================================== |
17 |
Patch from http://bugzilla.xfce.org/show_bug.cgi?id=9952 with modification |
18 |
to edit configure.ac (release tarball) instead of configure.ac.in (git) |
19 |
|
20 |
From ee2228c756e40a4289476f40a6d0045d17418bce Mon Sep 17 00:00:00 2001 |
21 |
From: Eric Koegel <eric.koegel@×××××.com> |
22 |
Date: Thu, 29 May 2014 19:17:26 +0300 |
23 |
Subject: [PATCH] Add suspend/hibernate to shutdown-helper |
24 |
|
25 |
Upower 0.99 dropped support for suspend/hibernate as an obsolete |
26 |
feature in this commit: |
27 |
http://cgit.freedesktop.org/upower/commit/?id=1ee642e705a63f5ad56a6b55e4bf5c4a64c959b8 |
28 |
Add that functionality into the shutdown-helper so these features |
29 |
will work again. |
30 |
--- |
31 |
configure.ac.in | 27 +++++++++ |
32 |
xfce4-session/Makefile.am | 4 +- |
33 |
xfce4-session/xfsm-shutdown.c | 126 ++++++++++++++++++++++++++++++++++++++++-- |
34 |
xfce4-session/xfsm-upower.c | 5 +- |
35 |
xfce4-session/xfsm-upower.h | 4 ++ |
36 |
xfsm-shutdown-helper/main.c | 26 +++++++++ |
37 |
6 files changed, 186 insertions(+), 6 deletions(-) |
38 |
|
39 |
diff --git a/configure.ac b/configure.ac |
40 |
index 910fd35..d4557a4 100644 |
41 |
--- a/configure.ac |
42 |
+++ b/configure.ac |
43 |
@@ -95,6 +95,7 @@ XDT_CHECK_PACKAGE([LIBWNCK], [libwnck-1.0], [2.30]) |
44 |
XDT_CHECK_PACKAGE([DBUS], [dbus-1], [1.1.0]) |
45 |
XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.84]) |
46 |
XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.9.0]) |
47 |
+XDT_CHECK_PACKAGE([UPOWER],[upower-glib], [0.9.8]) |
48 |
|
49 |
dnl Check for polkit / systemd integration |
50 |
XDT_CHECK_OPTIONAL_PACKAGE([SYSTEMD], [polkit-gobject-1], [0.100], |
51 |
@@ -157,6 +158,31 @@ if test "x$linux_ioprio_works" = "xyes"; then |
52 |
[Defined if linux/ioprio.h not only exists, but works properly]) |
53 |
fi |
54 |
|
55 |
+dnl Compile time default choice of backend |
56 |
+AC_ARG_WITH([backend], |
57 |
+ AS_HELP_STRING([--with-backend=<option>], |
58 |
+ [Default backend to use linux, freebsd, openbsd])) |
59 |
+# default to a sane option |
60 |
+AC_CANONICAL_HOST |
61 |
+if test x$with_backend = x; then |
62 |
+ AS_CASE([$host], |
63 |
+ [*-linux*], [with_backend=linux], |
64 |
+ [*-*freebsd*], [with_backend=freebsd], |
65 |
+ [*-openbsd*], [with_backend=openbsd]) |
66 |
+fi |
67 |
+AC_DEFINE_UNQUOTED(BACKEND, "$with_backend", [backend]) |
68 |
+AC_SUBST(BACKEND, "$with_backend") |
69 |
+ |
70 |
+if test x$with_backend = xlinux; then |
71 |
+ AC_DEFINE(BACKEND_TYPE_LINUX, 1, [Linux suspend/hibernate backend]) |
72 |
+fi |
73 |
+if test x$with_backend = xfreebsd; then |
74 |
+ AC_DEFINE(BACKEND_TYPE_FREEBSD, 1, [FreeBSD suspend/hibernate backend]) |
75 |
+fi |
76 |
+if test x$with_backend = xopenbsd; then |
77 |
+ AC_DEFINE(BACKEND_TYPE_OPENBSD, 1, [OpenBSD suspend/hibernate backend]) |
78 |
+fi |
79 |
+ |
80 |
dnl check for location Xfce glade files were installed to |
81 |
XFCE_GLADE_CATALOG_PATH="`pkg-config --variable glade_catalogdir libxfce4ui-1`" |
82 |
XFCE_GLADE_PIXMAP_PATH="`pkg-config --variable glade_pixmapdir libxfce4ui-1`" |
83 |
@@ -207,5 +233,6 @@ echo " * Gnome Keyring support: yes" |
84 |
else |
85 |
echo " * Gnome Keyring support: no" |
86 |
fi |
87 |
+echo " * Backend: ${with_backend}" |
88 |
|
89 |
echo |
90 |
diff --git a/xfce4-session/Makefile.am b/xfce4-session/Makefile.am |
91 |
index 5472b33..6b5968e 100644 |
92 |
--- a/xfce4-session/Makefile.am |
93 |
+++ b/xfce4-session/Makefile.am |
94 |
@@ -83,7 +83,8 @@ xfce4_session_CFLAGS = \ |
95 |
$(SYSTEMD_CFLAGS) \ |
96 |
$(XFCONF_CFLAGS) \ |
97 |
$(GMODULE_CFLAGS) \ |
98 |
- $(PLATFORM_CFLAGS) |
99 |
+ $(PLATFORM_CFLAGS) \ |
100 |
+ $(UPOWER_CFLAGS) |
101 |
|
102 |
xfce4_session_LDFLAGS = \ |
103 |
-no-undefined \ |
104 |
@@ -102,6 +103,7 @@ xfce4_session_LDADD = \ |
105 |
$(LIBWNCK_LIBS) \ |
106 |
$(SYSTEMD_LIBS) \ |
107 |
$(XFCONF_LIBS) \ |
108 |
+ $(UPOWER_LIBS) \ |
109 |
-lm |
110 |
|
111 |
xfce4_session_DEPENDENCIES = \ |
112 |
diff --git a/xfce4-session/xfsm-shutdown.c b/xfce4-session/xfsm-shutdown.c |
113 |
index 4c483a7..cba08b8 100644 |
114 |
--- a/xfce4-session/xfsm-shutdown.c |
115 |
+++ b/xfce4-session/xfsm-shutdown.c |
116 |
@@ -57,6 +57,7 @@ |
117 |
#include <dbus/dbus-glib-lowlevel.h> |
118 |
#include <libxfce4util/libxfce4util.h> |
119 |
#include <gtk/gtk.h> |
120 |
+#include <upower.h> |
121 |
|
122 |
#include <libxfsm/xfsm-util.h> |
123 |
|
124 |
@@ -76,6 +77,8 @@ |
125 |
|
126 |
static void xfsm_shutdown_finalize (GObject *object); |
127 |
static void xfsm_shutdown_sudo_free (XfsmShutdown *shutdown); |
128 |
+static gboolean xfsm_shutdown_fallback_can_hibernate (void); |
129 |
+static gboolean xfsm_shutdown_fallback_can_suspend (void); |
130 |
|
131 |
|
132 |
|
133 |
@@ -403,14 +406,16 @@ xfsm_shutdown_sudo_try_action (XfsmShutdown *shutdown, |
134 |
g_return_val_if_fail (shutdown->helper_state == SUDO_AVAILABLE, FALSE); |
135 |
g_return_val_if_fail (shutdown->helper_outfile != NULL, FALSE); |
136 |
g_return_val_if_fail (shutdown->helper_infile != NULL, FALSE); |
137 |
- g_return_val_if_fail (type == XFSM_SHUTDOWN_SHUTDOWN |
138 |
- || type == XFSM_SHUTDOWN_RESTART, FALSE); |
139 |
|
140 |
/* the command we send to sudo */ |
141 |
if (type == XFSM_SHUTDOWN_SHUTDOWN) |
142 |
action = "POWEROFF"; |
143 |
else if (type == XFSM_SHUTDOWN_RESTART) |
144 |
action = "REBOOT"; |
145 |
+ else if (type == XFSM_SHUTDOWN_SUSPEND) |
146 |
+ action = "SUSPEND"; |
147 |
+ else if (type == XFSM_SHUTDOWN_HIBERNATE) |
148 |
+ action = "HIBERNATE"; |
149 |
else |
150 |
return FALSE; |
151 |
|
152 |
@@ -692,7 +697,17 @@ xfsm_shutdown_try_suspend (XfsmShutdown *shutdown, |
153 |
{ |
154 |
g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); |
155 |
|
156 |
- return xfsm_upower_try_suspend (shutdown->upower, error); |
157 |
+#if UP_CHECK_VERSION(0, 99, 0) |
158 |
+ if (shutdown->helper_state == SUDO_AVAILABLE) |
159 |
+ { |
160 |
+ xfsm_upower_lock_screen (shutdown->upower, "Suspend", error); |
161 |
+ return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_SUSPEND, error); |
162 |
+ } |
163 |
+ else |
164 |
+ return FALSE; |
165 |
+#else |
166 |
+ return xfsm_upower_try_suspend (shutdown->upower, error); |
167 |
+#endif |
168 |
} |
169 |
|
170 |
|
171 |
@@ -703,7 +718,17 @@ xfsm_shutdown_try_hibernate (XfsmShutdown *shutdown, |
172 |
{ |
173 |
g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); |
174 |
|
175 |
- return xfsm_upower_try_hibernate (shutdown->upower, error); |
176 |
+#if UP_CHECK_VERSION(0, 99, 0) |
177 |
+ if (shutdown->helper_state == SUDO_AVAILABLE) |
178 |
+ { |
179 |
+ xfsm_upower_lock_screen (shutdown->upower, "Hibernate", error); |
180 |
+ return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_HIBERNATE, error); |
181 |
+ } |
182 |
+ else |
183 |
+ return FALSE; |
184 |
+#else |
185 |
+ return xfsm_upower_try_hibernate (shutdown->upower, error); |
186 |
+#endif |
187 |
} |
188 |
|
189 |
|
190 |
@@ -784,8 +809,13 @@ xfsm_shutdown_can_suspend (XfsmShutdown *shutdown, |
191 |
return TRUE; |
192 |
} |
193 |
|
194 |
+#if UP_CHECK_VERSION(0, 99, 0) |
195 |
+ *can_suspend = xfsm_shutdown_fallback_can_suspend (); |
196 |
+ return TRUE; |
197 |
+#else |
198 |
return xfsm_upower_can_suspend (shutdown->upower, can_suspend, |
199 |
auth_suspend, error); |
200 |
+#endif |
201 |
} |
202 |
|
203 |
|
204 |
@@ -804,8 +834,13 @@ xfsm_shutdown_can_hibernate (XfsmShutdown *shutdown, |
205 |
return TRUE; |
206 |
} |
207 |
|
208 |
+#if UP_CHECK_VERSION(0, 99, 0) |
209 |
+ *can_hibernate = xfsm_shutdown_fallback_can_hibernate (); |
210 |
+ return TRUE; |
211 |
+#else |
212 |
return xfsm_upower_can_hibernate (shutdown->upower, can_hibernate, |
213 |
auth_hibernate, error); |
214 |
+#endif |
215 |
} |
216 |
|
217 |
|
218 |
@@ -816,3 +851,86 @@ xfsm_shutdown_can_save_session (XfsmShutdown *shutdown) |
219 |
g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); |
220 |
return shutdown->kiosk_can_save_session; |
221 |
} |
222 |
+ |
223 |
+ |
224 |
+ |
225 |
+#ifdef BACKEND_TYPE_FREEBSD |
226 |
+static gboolean |
227 |
+freebsd_supports_sleep_state (const gchar *state) |
228 |
+{ |
229 |
+ gboolean ret = FALSE; |
230 |
+ gchar *sleep_states; |
231 |
+ |
232 |
+ sleep_states = up_get_string_sysctl (NULL, "hw.acpi.supported_sleep_state"); |
233 |
+ if (sleep_states != NULL) |
234 |
+ { |
235 |
+ if (strstr (sleep_states, state) != NULL) |
236 |
+ ret = TRUE; |
237 |
+ } |
238 |
+ |
239 |
+ g_free (sleep_states); |
240 |
+ |
241 |
+ return ret; |
242 |
+} |
243 |
+#endif |
244 |
+ |
245 |
+#ifdef BACKEND_TYPE_LINUX |
246 |
+static gboolean |
247 |
+linux_supports_sleep_state (const gchar *state) |
248 |
+{ |
249 |
+ gboolean ret = FALSE; |
250 |
+ gchar *command; |
251 |
+ GError *error = NULL; |
252 |
+ gint exit_status; |
253 |
+ |
254 |
+ /* run script from pm-utils */ |
255 |
+ command = g_strdup_printf ("/usr/bin/pm-is-supported --%s", state); |
256 |
+ |
257 |
+ ret = g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error); |
258 |
+ if (!ret) |
259 |
+ { |
260 |
+ g_warning ("failed to run script: %s", error->message); |
261 |
+ g_error_free (error); |
262 |
+ goto out; |
263 |
+ } |
264 |
+ ret = (WIFEXITED(exit_status) && (WEXITSTATUS(exit_status) == EXIT_SUCCESS)); |
265 |
+ |
266 |
+out: |
267 |
+ g_free (command); |
268 |
+ |
269 |
+ return ret; |
270 |
+} |
271 |
+#endif |
272 |
+ |
273 |
+ |
274 |
+static gboolean |
275 |
+xfsm_shutdown_fallback_can_suspend (void) |
276 |
+{ |
277 |
+#ifdef BACKEND_TYPE_FREEBSD |
278 |
+ return freebsd_supports_sleep_state ("S3"); |
279 |
+#endif |
280 |
+#ifdef BACKEND_TYPE_LINUX |
281 |
+ return linux_supports_sleep_state ("suspend"); |
282 |
+#endif |
283 |
+#ifdef BACKEND_TYPE_OPENBSD |
284 |
+ return TRUE; |
285 |
+#endif |
286 |
+ |
287 |
+ return FALSE; |
288 |
+} |
289 |
+ |
290 |
+static gboolean |
291 |
+xfsm_shutdown_fallback_can_hibernate (void) |
292 |
+{ |
293 |
+#ifdef BACKEND_TYPE_FREEBSD |
294 |
+ return freebsd_supports_sleep_state ("S4"); |
295 |
+#endif |
296 |
+#ifdef BACKEND_TYPE_LINUX |
297 |
+ return linux_supports_sleep_state ("hibernate"); |
298 |
+#endif |
299 |
+#ifdef BACKEND_TYPE_OPENBSD |
300 |
+ return FALSE; |
301 |
+#endif |
302 |
+ |
303 |
+ return FALSE; |
304 |
+} |
305 |
diff --git a/xfce4-session/xfsm-upower.c b/xfce4-session/xfsm-upower.c |
306 |
index 57402ec..8112829 100644 |
307 |
--- a/xfce4-session/xfsm-upower.c |
308 |
+++ b/xfce4-session/xfsm-upower.c |
309 |
@@ -21,6 +21,7 @@ |
310 |
|
311 |
#include <dbus/dbus-glib.h> |
312 |
#include <dbus/dbus-glib-lowlevel.h> |
313 |
+#include <upower.h> |
314 |
|
315 |
#include <libxfsm/xfsm-util.h> |
316 |
#include <xfce4-session/xfsm-upower.h> |
317 |
@@ -283,7 +284,7 @@ xfsm_upower_try_method (XfsmUPower *upower, |
318 |
|
319 |
|
320 |
|
321 |
-static gboolean |
322 |
+gboolean |
323 |
xfsm_upower_lock_screen (XfsmUPower *upower, |
324 |
const gchar *sleep_kind, |
325 |
GError **error) |
326 |
@@ -299,6 +300,7 @@ xfsm_upower_lock_screen (XfsmUPower *upower, |
327 |
{ |
328 |
if (xfsm_upower_proxy_ensure (upower, error)) |
329 |
{ |
330 |
+#if !UP_CHECK_VERSION(0, 99, 0) |
331 |
/* tell upower we're going to sleep, this saves some |
332 |
* time while we sleep 1 second if xflock4 is spawned */ |
333 |
ret = dbus_g_proxy_call (upower->upower_proxy, |
334 |
@@ -312,6 +314,7 @@ xfsm_upower_lock_screen (XfsmUPower *upower, |
335 |
g_warning ("Couldn't sent that we were about to sleep: %s", err->message); |
336 |
g_error_free (err); |
337 |
} |
338 |
+#endif |
339 |
} |
340 |
else |
341 |
{ |
342 |
diff --git a/xfce4-session/xfsm-upower.h b/xfce4-session/xfsm-upower.h |
343 |
index a492f7d..4e6a53b 100644 |
344 |
--- a/xfce4-session/xfsm-upower.h |
345 |
+++ b/xfce4-session/xfsm-upower.h |
346 |
@@ -51,4 +51,8 @@ gboolean xfsm_upower_can_hibernate (XfsmUPower *upower, |
347 |
gboolean *auth_hibernate, |
348 |
GError **error); |
349 |
|
350 |
+gboolean xfsm_upower_lock_screen (XfsmUPower *upower, |
351 |
+ const gchar *sleep_kind, |
352 |
+ GError **error); |
353 |
+ |
354 |
#endif /* !__XFSM_UPOWER_HELPER_H__ */ |
355 |
diff --git a/xfsm-shutdown-helper/main.c b/xfsm-shutdown-helper/main.c |
356 |
index 667f288..60c621b 100644 |
357 |
--- a/xfsm-shutdown-helper/main.c |
358 |
+++ b/xfsm-shutdown-helper/main.c |
359 |
@@ -57,6 +57,12 @@ |
360 |
#ifdef REBOOT_CMD |
361 |
#undef REBOOT_CMD |
362 |
#endif |
363 |
+#ifdef UP_BACKEND_SUSPEND_COMMAND |
364 |
+#undef UP_BACKEND_SUSPEND_COMMAND |
365 |
+#endif |
366 |
+#ifdef UP_BACKEND_HIBERNATE_COMMAND |
367 |
+#undef UP_BACKEND_HIBERNATE_COMMAND |
368 |
+#endif |
369 |
|
370 |
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) |
371 |
#define POWEROFF_CMD "/sbin/shutdown -p now" |
372 |
@@ -68,6 +74,18 @@ |
373 |
#define POWEROFF_CMD "/sbin/shutdown -h now" |
374 |
#define REBOOT_CMD "/sbin/shutdown -r now" |
375 |
#endif |
376 |
+#ifdef BACKEND_TYPE_FREEBSD |
377 |
+#define UP_BACKEND_SUSPEND_COMMAND "/usr/sbin/zzz" |
378 |
+#define UP_BACKEND_HIBERNATE_COMMAND "/usr/sbin/acpiconf -s 4" |
379 |
+#endif |
380 |
+#if BACKEND_TYPE_LINUX |
381 |
+#define UP_BACKEND_SUSPEND_COMMAND "/usr/sbin/pm-suspend" |
382 |
+#define UP_BACKEND_HIBERNATE_COMMAND "/usr/sbin/pm-hibernate" |
383 |
+#endif |
384 |
+#ifdef BACKEND_TYPE_OPENBSD |
385 |
+#define UP_BACKEND_SUSPEND_COMMAND "/usr/sbin/zzz" |
386 |
+#define UP_BACKEND_HIBERNATE_COMMAND "/dev/null" |
387 |
+#endif |
388 |
|
389 |
|
390 |
static gboolean |
391 |
@@ -143,6 +161,14 @@ main (int argc, char **argv) |
392 |
{ |
393 |
succeed = run (REBOOT_CMD); |
394 |
} |
395 |
+ else if (strncasecmp (action, "SUSPEND", 7) == 0) |
396 |
+ { |
397 |
+ succeed = run (UP_BACKEND_SUSPEND_COMMAND); |
398 |
+ } |
399 |
+ else if (strncasecmp (action, "HIBERNATE", 9) == 0) |
400 |
+ { |
401 |
+ succeed = run (UP_BACKEND_HIBERNATE_COMMAND); |
402 |
+ } |
403 |
|
404 |
if (succeed) |
405 |
{ |
406 |
-- |
407 |
1.9.3 |