Merge lp:~ballogy/docky/systemd-support into lp:docky

Proposed by Balló György
Status: Merged
Merged at revision: 1831
Proposed branch: lp:~ballogy/docky/systemd-support
Merge into: lp:docky
Diff against target: 143 lines (+43/-12)
1 file modified
StandardPlugins/SessionManager/src/SystemManager.cs (+43/-12)
To merge this branch: bzr merge lp:~ballogy/docky/systemd-support
Reviewer Review Type Date Requested Status
Rico Tzschichholz Approve
Review via email: mp+141473@code.launchpad.net

Description of the change

This change adds the following improvements for the Session Manager plugin:

1. Add support for reboot and power off with systemd-logind[1]. ConsoleKit is deprecated now, and no longer available on Arch Linux.

2. Fix GNOME Session support. gnome-session-save has been renamed to gnome-session-quit, and the parameters are changed.

3 Fix missing icon on the restart dialog. "system-restart" is not available in gnome-icon-theme 3.6, so the general fallback icon (broken image) displayed instead.

[1] http://www.freedesktop.org/wiki/Software/systemd/logind

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Thanks for this!

There are some things needs to be changed.
It is better to do the icon fixing in another branch since what you have done isn't enough yet.
Use string.Equals for checking equality of strings.
Using "No session bus available" suggests it is a dbus-related problem, so "No consolekit or systemd bus available" is better.

review: Needs Fixing
lp:~ballogy/docky/systemd-support updated
1832. By Balló György

Fixes

Revision history for this message
Balló György (ballogy) wrote :

Now I changed the things that you mentioned.

Revision history for this message
Rico Tzschichholz (ricotz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'StandardPlugins/SessionManager/src/SystemManager.cs'
--- StandardPlugins/SessionManager/src/SystemManager.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/SessionManager/src/SystemManager.cs 2012-12-31 04:31:20 +0000
@@ -41,6 +41,10 @@
41 const string DeviceKitPowerPath = "/org/freedesktop/DeviceKit/Power";41 const string DeviceKitPowerPath = "/org/freedesktop/DeviceKit/Power";
42 const string DeviceKitPowerIface = "org.freedesktop.DeviceKit.Power";42 const string DeviceKitPowerIface = "org.freedesktop.DeviceKit.Power";
4343
44 const string SystemdName = "org.freedesktop.login1";
45 const string SystemdPath = "/org/freedesktop/login1";
46 const string SystemdIface = "org.freedesktop.login1.Manager";
47
44 const string ConsoleKitName = "org.freedesktop.ConsoleKit";48 const string ConsoleKitName = "org.freedesktop.ConsoleKit";
45 const string ConsoleKitPath = "/org/freedesktop/ConsoleKit/Manager";49 const string ConsoleKitPath = "/org/freedesktop/ConsoleKit/Manager";
46 const string ConsoleKitIface = "org.freedesktop.ConsoleKit.Manager";50 const string ConsoleKitIface = "org.freedesktop.ConsoleKit.Manager";
@@ -79,6 +83,16 @@
79 event Action Changed;83 event Action Changed;
80 }84 }
8185
86 [Interface (SystemdIface)]
87 interface ISystemd
88 {
89 string CanPowerOff ();
90 string CanReboot ();
91
92 void PowerOff (bool interactive);
93 void Reboot (bool interactive);
94 }
95
82 [Interface (ConsoleKitIface)]96 [Interface (ConsoleKitIface)]
83 interface IConsoleKit97 interface IConsoleKit
84 {98 {
@@ -100,6 +114,7 @@
100 114
101 IDeviceKitPower devicekit;115 IDeviceKitPower devicekit;
102 IUPower upower;116 IUPower upower;
117 ISystemd systemd;
103 IConsoleKit consolekit;118 IConsoleKit consolekit;
104 119
105 private static SystemManager instance;120 private static SystemManager instance;
@@ -117,7 +132,7 @@
117 SystemBus = Bus.System.GetObject<IBus> ("org.freedesktop.DBus", new ObjectPath ("/org/freedesktop/DBus"));132 SystemBus = Bus.System.GetObject<IBus> ("org.freedesktop.DBus", new ObjectPath ("/org/freedesktop/DBus"));
118 133
119 SystemBus.NameOwnerChanged += delegate(string name, string old_owner, string new_owner) {134 SystemBus.NameOwnerChanged += delegate(string name, string old_owner, string new_owner) {
120 if (name != UPowerName && name != DeviceKitPowerName && name != ConsoleKitName)135 if (name != UPowerName && name != DeviceKitPowerName && name != SystemdName && name != ConsoleKitName)
121 return;136 return;
122137
123 Log<SystemManager>.Debug ("DBus services changed, reconnecting now");138 Log<SystemManager>.Debug ("DBus services changed, reconnecting now");
@@ -128,6 +143,9 @@
128 if (devicekit != null)143 if (devicekit != null)
129 devicekit = null;144 devicekit = null;
130145
146 if (systemd != null)
147 systemd = null;
148
131 if (consolekit != null)149 if (consolekit != null)
132 consolekit = null;150 consolekit = null;
133 151
@@ -161,7 +179,10 @@
161 Log<SystemManager>.Debug ("Using DeviceKit.Power dbus service");179 Log<SystemManager>.Debug ("Using DeviceKit.Power dbus service");
162 }180 }
163 181
164 if (consolekit == null && Bus.System.NameHasOwner (ConsoleKitName)) {182 if (systemd == null && Bus.System.NameHasOwner (SystemdName)) {
183 systemd = Bus.System.GetObject<ISystemd> (SystemdName, new ObjectPath (SystemdPath));
184 Log<SystemManager>.Debug ("Using login1.Manager dbus service");
185 } else if (consolekit == null && Bus.System.NameHasOwner (ConsoleKitName)) {
165 consolekit = Bus.System.GetObject<IConsoleKit> (ConsoleKitName, new ObjectPath (ConsoleKitPath));186 consolekit = Bus.System.GetObject<IConsoleKit> (ConsoleKitName, new ObjectPath (ConsoleKitPath));
166 Log<SystemManager>.Debug ("Using ConsoleKit.Manager dbus service");187 Log<SystemManager>.Debug ("Using ConsoleKit.Manager dbus service");
167 }188 }
@@ -261,39 +282,49 @@
261 282
262 public bool CanRestart ()283 public bool CanRestart ()
263 {284 {
264 if (consolekit != null)285 if (systemd != null)
286 return String.Equals (systemd.CanReboot (), "yes");
287 else if (consolekit != null)
265 return consolekit.CanRestart ();288 return consolekit.CanRestart ();
266 289
267 Log<SystemManager>.Debug ("No consolekit bus available");290 Log<SystemManager>.Debug ("No consolekit or systemd bus available");
268 return false;291 return false;
269 }292 }
270293
271 public void Restart ()294 public void Restart ()
272 {295 {
273 if (consolekit != null) {296 if (systemd != null) {
297 if (String.Equals (systemd.CanReboot (), "yes"))
298 systemd.Reboot (true);
299 } else if (consolekit != null) {
274 if (consolekit.CanRestart ())300 if (consolekit.CanRestart ())
275 consolekit.Restart ();301 consolekit.Restart ();
276 } else {302 } else {
277 Log<SystemManager>.Debug ("No consolekit bus available");303 Log<SystemManager>.Debug ("No consolekit or systemd bus available");
278 }304 }
279 }305 }
280306
281 public bool CanStop ()307 public bool CanStop ()
282 {308 {
283 if (consolekit != null)309 if (systemd != null)
310 return String.Equals (systemd.CanPowerOff (), "yes");
311 else if (consolekit != null)
284 return consolekit.CanStop ();312 return consolekit.CanStop ();
285 313
286 Log<SystemManager>.Debug ("No consolekit bus available");314 Log<SystemManager>.Debug ("No consolekit or systemd bus available");
287 return false;315 return false;
288 }316 }
289317
290 public void Stop ()318 public void Stop ()
291 {319 {
292 if (consolekit != null) {320 if (systemd != null) {
321 if (String.Equals (systemd.CanPowerOff (), "yes"))
322 systemd.PowerOff (true);
323 } else if (consolekit != null) {
293 if (consolekit.CanStop ())324 if (consolekit.CanStop ())
294 consolekit.Stop ();325 consolekit.Stop ();
295 } else {326 } else {
296 Log<SystemManager>.Debug ("No consolekit bus available");327 Log<SystemManager>.Debug ("No consolekit or systemd bus available");
297 }328 }
298 }329 }
299 330
@@ -309,12 +340,12 @@
309 340
310 public bool CanLogOut ()341 public bool CanLogOut ()
311 {342 {
312 return DockServices.System.IsValidExecutable ("gnome-session-save");343 return DockServices.System.IsValidExecutable ("gnome-session-quit");
313 }344 }
314 345
315 public void LogOut ()346 public void LogOut ()
316 {347 {
317 DockServices.System.Execute ("gnome-session-save --logout");348 DockServices.System.Execute ("gnome-session-quit --logout --no-prompt");
318 }349 }
319 350
320 public void Dispose ()351 public void Dispose ()

Subscribers

People subscribed via source and target branches

to status/vote changes: