Skip to content

Commit c3e881b

Browse files
EricKoegelplfiorini
authored andcommitted
ConsoleKit2 support for system actions
This adds support for calling ConsoleKit2's DBUS API for shutdown, reboot, suspend, and hibernate. It does so by using the exact same interface as login1, making it a shared seat manager backend.
1 parent 77f1a5d commit c3e881b

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

INSTALL

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ its home set to `/var/lib/sddm` by default.
3030
SDDM depends on PAM for authorization and XCB to communicate with the X server.
3131
Apart from other things, it also depends on Qt for the user interface and event
3232
loop management.
33-
SDDM can optionally make use of logind (the systemd login manager API) or
34-
upower to enable support for suspend, hibernate etc.
33+
SDDM can optionally make use of logind (the systemd login manager API), or
34+
ConsoleKit2, or upower to enable support for suspend, hibernate etc.
3535
In order to build the man pages, you will need `rst2man` installed. It is
3636
provided by the python `docutils` package
3737

src/daemon/PowerManager.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ namespace SDDM {
5959

6060
class UPowerBackend : public PowerManagerBackend {
6161
public:
62-
UPowerBackend() {
63-
m_interface = new QDBusInterface(UPOWER_SERVICE, UPOWER_PATH, UPOWER_OBJECT, QDBusConnection::systemBus());
62+
UPowerBackend(const QString & service, const QString & path, const QString & interface) {
63+
m_interface = new QDBusInterface(service, path, interface, QDBusConnection::systemBus());
6464
}
6565

6666
~UPowerBackend() {
@@ -110,20 +110,24 @@ namespace SDDM {
110110
};
111111

112112
/**********************************************/
113-
/* LOGIN1 BACKEND */
113+
/* LOGIN1 && ConsoleKit2 BACKEND */
114114
/**********************************************/
115115

116116
#define LOGIN1_SERVICE QStringLiteral("org.freedesktop.login1")
117117
#define LOGIN1_PATH QStringLiteral("/org/freedesktop/login1")
118118
#define LOGIN1_OBJECT QStringLiteral("org.freedesktop.login1.Manager")
119119

120-
class Login1Backend : public PowerManagerBackend {
120+
#define CK2_SERVICE QStringLiteral("org.freedesktop.ConsoleKit")
121+
#define CK2_PATH QStringLiteral("/org/freedesktop/ConsoleKit/Manager")
122+
#define CK2_OBJECT QStringLiteral("org.freedesktop.ConsoleKit.Manager")
123+
124+
class SeatManagerBackend : public PowerManagerBackend {
121125
public:
122-
Login1Backend() {
123-
m_interface = new QDBusInterface(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_OBJECT, QDBusConnection::systemBus());
126+
SeatManagerBackend(const QString & service, const QString & path, const QString & interface) {
127+
m_interface = new QDBusInterface(service, path, interface, QDBusConnection::systemBus());
124128
}
125129

126-
~Login1Backend() {
130+
~SeatManagerBackend() {
127131
delete m_interface;
128132
}
129133

@@ -194,11 +198,15 @@ namespace SDDM {
194198

195199
// check if login1 interface exists
196200
if (interface->isServiceRegistered(LOGIN1_SERVICE))
197-
m_backends << new Login1Backend();
201+
m_backends << new SeatManagerBackend(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_OBJECT);
202+
203+
// check if ConsoleKit2 interface exists
204+
if (interface->isServiceRegistered(CK2_SERVICE))
205+
m_backends << new SeatManagerBackend(CK2_SERVICE, CK2_PATH, CK2_OBJECT);
198206

199207
// check if upower interface exists
200208
if (interface->isServiceRegistered(UPOWER_SERVICE))
201-
m_backends << new UPowerBackend();
209+
m_backends << new UPowerBackend(UPOWER_SERVICE, UPOWER_PATH, UPOWER_OBJECT);
202210
}
203211

204212
PowerManager::~PowerManager() {

0 commit comments

Comments
 (0)