mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
Use HAL as fallback for system shutdown/suspend
This commit is contained in:
parent
c63503aaa6
commit
dc2de49cdb
18
src/misc.cpp
18
src/misc.cpp
@ -211,13 +211,31 @@ void misc::shutdownComputer(bool sleep) {
|
|||||||
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||||
// Use dbus to power off / suspend the system
|
// Use dbus to power off / suspend the system
|
||||||
if(sleep) {
|
if(sleep) {
|
||||||
|
// Recent systems use UPower
|
||||||
QDBusInterface upowerIface("org.freedesktop.UPower", "/org/freedesktop/UPower",
|
QDBusInterface upowerIface("org.freedesktop.UPower", "/org/freedesktop/UPower",
|
||||||
"org.freedesktop.UPower", QDBusConnection::systemBus());
|
"org.freedesktop.UPower", QDBusConnection::systemBus());
|
||||||
|
if(upowerIface.isValid()) {
|
||||||
upowerIface.call("Suspend");
|
upowerIface.call("Suspend");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// HAL (older systems)
|
||||||
|
QDBusInterface halIface("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer",
|
||||||
|
"org.freedesktop.Hal.Device.SystemPowerManagement",
|
||||||
|
QDBusConnection::systemBus());
|
||||||
|
halIface.call("Suspend", 5);
|
||||||
} else {
|
} else {
|
||||||
|
// Recent systems use ConsoleKit
|
||||||
QDBusInterface consolekitIface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager",
|
QDBusInterface consolekitIface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager",
|
||||||
"org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus());
|
"org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus());
|
||||||
|
if(consolekitIface.isValid()) {
|
||||||
consolekitIface.call("Stop");
|
consolekitIface.call("Stop");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// HAL (older systems)
|
||||||
|
QDBusInterface halIface("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer",
|
||||||
|
"org.freedesktop.Hal.Device.SystemPowerManagement",
|
||||||
|
QDBusConnection::systemBus());
|
||||||
|
halIface.call("Shutdown");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
|
Loading…
Reference in New Issue
Block a user