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
1=== modified file 'StandardPlugins/SessionManager/src/SystemManager.cs'
2--- StandardPlugins/SessionManager/src/SystemManager.cs 2010-10-09 12:54:14 +0000
3+++ StandardPlugins/SessionManager/src/SystemManager.cs 2012-12-31 04:31:20 +0000
4@@ -41,6 +41,10 @@
5 const string DeviceKitPowerPath = "/org/freedesktop/DeviceKit/Power";
6 const string DeviceKitPowerIface = "org.freedesktop.DeviceKit.Power";
7
8+ const string SystemdName = "org.freedesktop.login1";
9+ const string SystemdPath = "/org/freedesktop/login1";
10+ const string SystemdIface = "org.freedesktop.login1.Manager";
11+
12 const string ConsoleKitName = "org.freedesktop.ConsoleKit";
13 const string ConsoleKitPath = "/org/freedesktop/ConsoleKit/Manager";
14 const string ConsoleKitIface = "org.freedesktop.ConsoleKit.Manager";
15@@ -79,6 +83,16 @@
16 event Action Changed;
17 }
18
19+ [Interface (SystemdIface)]
20+ interface ISystemd
21+ {
22+ string CanPowerOff ();
23+ string CanReboot ();
24+
25+ void PowerOff (bool interactive);
26+ void Reboot (bool interactive);
27+ }
28+
29 [Interface (ConsoleKitIface)]
30 interface IConsoleKit
31 {
32@@ -100,6 +114,7 @@
33
34 IDeviceKitPower devicekit;
35 IUPower upower;
36+ ISystemd systemd;
37 IConsoleKit consolekit;
38
39 private static SystemManager instance;
40@@ -117,7 +132,7 @@
41 SystemBus = Bus.System.GetObject<IBus> ("org.freedesktop.DBus", new ObjectPath ("/org/freedesktop/DBus"));
42
43 SystemBus.NameOwnerChanged += delegate(string name, string old_owner, string new_owner) {
44- if (name != UPowerName && name != DeviceKitPowerName && name != ConsoleKitName)
45+ if (name != UPowerName && name != DeviceKitPowerName && name != SystemdName && name != ConsoleKitName)
46 return;
47
48 Log<SystemManager>.Debug ("DBus services changed, reconnecting now");
49@@ -128,6 +143,9 @@
50 if (devicekit != null)
51 devicekit = null;
52
53+ if (systemd != null)
54+ systemd = null;
55+
56 if (consolekit != null)
57 consolekit = null;
58
59@@ -161,7 +179,10 @@
60 Log<SystemManager>.Debug ("Using DeviceKit.Power dbus service");
61 }
62
63- if (consolekit == null && Bus.System.NameHasOwner (ConsoleKitName)) {
64+ if (systemd == null && Bus.System.NameHasOwner (SystemdName)) {
65+ systemd = Bus.System.GetObject<ISystemd> (SystemdName, new ObjectPath (SystemdPath));
66+ Log<SystemManager>.Debug ("Using login1.Manager dbus service");
67+ } else if (consolekit == null && Bus.System.NameHasOwner (ConsoleKitName)) {
68 consolekit = Bus.System.GetObject<IConsoleKit> (ConsoleKitName, new ObjectPath (ConsoleKitPath));
69 Log<SystemManager>.Debug ("Using ConsoleKit.Manager dbus service");
70 }
71@@ -261,39 +282,49 @@
72
73 public bool CanRestart ()
74 {
75- if (consolekit != null)
76+ if (systemd != null)
77+ return String.Equals (systemd.CanReboot (), "yes");
78+ else if (consolekit != null)
79 return consolekit.CanRestart ();
80
81- Log<SystemManager>.Debug ("No consolekit bus available");
82+ Log<SystemManager>.Debug ("No consolekit or systemd bus available");
83 return false;
84 }
85
86 public void Restart ()
87 {
88- if (consolekit != null) {
89+ if (systemd != null) {
90+ if (String.Equals (systemd.CanReboot (), "yes"))
91+ systemd.Reboot (true);
92+ } else if (consolekit != null) {
93 if (consolekit.CanRestart ())
94 consolekit.Restart ();
95 } else {
96- Log<SystemManager>.Debug ("No consolekit bus available");
97+ Log<SystemManager>.Debug ("No consolekit or systemd bus available");
98 }
99 }
100
101 public bool CanStop ()
102 {
103- if (consolekit != null)
104+ if (systemd != null)
105+ return String.Equals (systemd.CanPowerOff (), "yes");
106+ else if (consolekit != null)
107 return consolekit.CanStop ();
108
109- Log<SystemManager>.Debug ("No consolekit bus available");
110+ Log<SystemManager>.Debug ("No consolekit or systemd bus available");
111 return false;
112 }
113
114 public void Stop ()
115 {
116- if (consolekit != null) {
117+ if (systemd != null) {
118+ if (String.Equals (systemd.CanPowerOff (), "yes"))
119+ systemd.PowerOff (true);
120+ } else if (consolekit != null) {
121 if (consolekit.CanStop ())
122 consolekit.Stop ();
123 } else {
124- Log<SystemManager>.Debug ("No consolekit bus available");
125+ Log<SystemManager>.Debug ("No consolekit or systemd bus available");
126 }
127 }
128
129@@ -309,12 +340,12 @@
130
131 public bool CanLogOut ()
132 {
133- return DockServices.System.IsValidExecutable ("gnome-session-save");
134+ return DockServices.System.IsValidExecutable ("gnome-session-quit");
135 }
136
137 public void LogOut ()
138 {
139- DockServices.System.Execute ("gnome-session-save --logout");
140+ DockServices.System.Execute ("gnome-session-quit --logout --no-prompt");
141 }
142
143 public void Dispose ()

Subscribers

People subscribed via source and target branches

to status/vote changes: