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