Merge lp:~ballogy/do-plugins/systemd-support into lp:do-plugins

Proposed by Balló György
Status: Needs review
Proposed branch: lp:~ballogy/do-plugins/systemd-support
Merge into: lp:do-plugins
Diff against target: 141 lines (+49/-15)
3 files modified
GNOME-Session/src/PowerManagement.cs (+1/-1)
GNOME-Session/src/SessionCommandsItemSource.cs (+5/-5)
GNOME-Session/src/SystemManagement.cs (+43/-9)
To merge this branch: bzr merge lp:~ballogy/do-plugins/systemd-support
Reviewer Review Type Date Requested Status
Do Plugins Team Pending
Review via email: mp+141505@code.launchpad.net

Description of the change

This change adds the following improvements for the GNOME-Session 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 icons on actions. "gnome-session-*" icons are not available in gnome-icon-theme 3.6, so the general fallback icon displayed instead.

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

To post a comment you must log in.

Unmerged revisions

754. By Balló György

Add systemd support for GNOME-Session plugin

And fix GNOME Session support, fix missing icons.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GNOME-Session/src/PowerManagement.cs'
2--- GNOME-Session/src/PowerManagement.cs 2011-08-06 11:38:07 +0000
3+++ GNOME-Session/src/PowerManagement.cs 2012-12-31 05:33:20 +0000
4@@ -134,7 +134,7 @@
5 public static void Logout ()
6 {
7 try {
8- Process.Start ("gnome-session-save", "--kill --silent");
9+ Process.Start ("gnome-session-quit", "--logout --no-prompt");
10 } catch (Exception e) {
11 Log<PowerManagement>.Error ("Could not logout: {0}", e.Message);
12 Log<PowerManagement>.Debug (e.StackTrace);
13
14=== modified file 'GNOME-Session/src/SessionCommandsItemSource.cs'
15--- GNOME-Session/src/SessionCommandsItemSource.cs 2010-03-17 15:01:40 +0000
16+++ GNOME-Session/src/SessionCommandsItemSource.cs 2012-12-31 05:33:20 +0000
17@@ -53,31 +53,31 @@
18 yield return new SessionCommandItem (
19 AddinManager.CurrentLocalizer.GetString ("Log Out"),
20 AddinManager.CurrentLocalizer.GetString ("Close your session and return to the login screen."),
21- "gnome-session-logout",
22+ "system-log-out",
23 PowerManagement.Logout);
24
25 yield return new SessionCommandItem (
26 AddinManager.CurrentLocalizer.GetString ("Shutdown"),
27 AddinManager.CurrentLocalizer.GetString ("Turn your computer off."),
28- "gnome-session-halt",
29+ "system-shutdown",
30 SystemManagement.Shutdown);
31
32 yield return new SessionCommandItem (
33 AddinManager.CurrentLocalizer.GetString ("Hibernate"),
34 AddinManager.CurrentLocalizer.GetString ("Put your computer into hibernation mode."),
35- "gnome-session-hibernate",
36+ "system-shutdown",
37 PowerManagement.Hibernate);
38
39 yield return new SessionCommandItem (
40 AddinManager.CurrentLocalizer.GetString ("Suspend"),
41 AddinManager.CurrentLocalizer.GetString ("Put your computer into suspend mode."),
42- "gnome-session-suspend",
43+ "system-shutdown",
44 PowerManagement.Suspend);
45
46 yield return new SessionCommandItem (
47 AddinManager.CurrentLocalizer.GetString ("Restart"),
48 AddinManager.CurrentLocalizer.GetString ("Restart your computer."),
49- "gnome-session-reboot",
50+ "system-shutdown",
51 SystemManagement.Restart);
52
53 yield return new SessionCommandItem (
54
55=== modified file 'GNOME-Session/src/SystemManagement.cs'
56--- GNOME-Session/src/SystemManagement.cs 2011-08-06 11:38:07 +0000
57+++ GNOME-Session/src/SystemManagement.cs 2012-12-31 05:33:20 +0000
58@@ -36,24 +36,48 @@
59 class SystemManagement
60 {
61 [Interface ("org.freedesktop.ConsoleKit.Manager")]
62- interface ISystemManagementProxy
63+ interface IConsoleKit
64 {
65 void Stop ();
66 void Restart ();
67 }
68
69- const string BusName = "org.freedesktop.ConsoleKit";
70- const string ObjectPath = "/org/freedesktop/ConsoleKit/Manager";
71-
72- static ISystemManagementProxy BusInstance
73+ [Interface ("org.freedesktop.login1.Manager")]
74+ interface ISystemd
75+ {
76+ void PowerOff (bool interactive);
77+ void Reboot (bool interactive);
78+ }
79+
80+ const string ConsoleKitName = "org.freedesktop.ConsoleKit";
81+ const string ConsoleKitPath = "/org/freedesktop/ConsoleKit/Manager";
82+ const string SystemdName = "org.freedesktop.login1";
83+ const string SystemdPath = "/org/freedesktop/login1";
84+
85+ static SystemManagement ()
86+ {
87+ try {
88+ BusG.Init ();
89+ } catch (Exception e) {
90+ Log<SystemManagement>.Error ("Could not initialize the bus: {0}", e.Message);
91+ Log<SystemManagement>.Debug (e.StackTrace);
92+ }
93+ }
94+
95+ static object BusInstance
96 {
97 get {
98 try {
99- return Bus.System.GetObject<ISystemManagementProxy> (BusName, new ObjectPath (ObjectPath));
100+ if (Bus.System.NameHasOwner (SystemdName)) {
101+ return Bus.System.GetObject<ISystemd> (SystemdName, new ObjectPath (SystemdPath));
102+ } else if (Bus.System.NameHasOwner (ConsoleKitName)) {
103+ return Bus.System.GetObject<IConsoleKit> (ConsoleKitName, new ObjectPath (ConsoleKitPath));
104+ }
105 } catch (Exception e) {
106- Log<SystemManagement>.Error ("Could not get ConsoleKit bus object: {0}", e.Message);
107+ Log<SystemManagement>.Error ("Could not get SystemManagement bus object: {0}", e.Message);
108 Log<SystemManagement>.Debug (e.StackTrace);
109 }
110+
111 return null;
112 }
113 }
114@@ -61,7 +85,12 @@
115 public static void Shutdown ()
116 {
117 try {
118- BusInstance.Stop ();
119+ object instance = BusInstance;
120+ if (instance is ISystemd) {
121+ (instance as ISystemd).PowerOff (true);
122+ } else if (instance is IConsoleKit) {
123+ (instance as IConsoleKit).Stop ();
124+ }
125 } catch (Exception e) {
126 Log<SystemManagement>.Error ("Could not shutdown: {0}", e.Message);
127 Log<SystemManagement>.Debug (e.StackTrace);
128@@ -71,7 +100,12 @@
129 public static void Restart ()
130 {
131 try {
132- BusInstance.Restart ();
133+ object instance = BusInstance;
134+ if (instance is ISystemd) {
135+ (instance as ISystemd).Reboot (true);
136+ } else if (instance is IConsoleKit) {
137+ (instance as IConsoleKit).Restart ();
138+ }
139 } catch (Exception e) {
140 Log<SystemManagement>.Error ("Could not reboot: {0}", e.Message);
141 Log<SystemManagement>.Debug (e.StackTrace);

Subscribers

People subscribed via source and target branches