Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#7749 closed enhancement (fixed)

When running under a managed session, use that session's tools to shutdown/reboot

Reported by: superm1@… Owned by: Isaac Richards
Priority: minor Milestone: 0.23
Component: MythTV - General Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

KDE, XFCE, & Gnome all support using their D-Bus interfaces to shutdown and reboot the system in some fashion. If one of those environment's session managers is running, it can be contacted and asked to reboot or halt the system.

If it can't be contacted, then you can fall back to the old style hardcoding of the halt/reboot commands.

Unfortunately this is broken in XFCE due to a bug in xfce-session, but when that bug is fixed, this code can be uncommented and included in myth too.

Attachments (4)

use_session_to_shutdown.patch (3.9 KB) - added by superm1@… 10 years ago.
use_session_or_console_kit.patch (3.8 KB) - added by superm1@… 10 years ago.
use_session_ck_hal.diff (4.8 KB) - added by superm1@… 10 years ago.
7749-config.patch (2.3 KB) - added by Nigel 10 years ago.
Something like this?

Download all attachments as: .zip

Change History (17)

Changed 10 years ago by superm1@…

Changed 10 years ago by superm1@…

comment:1 Changed 10 years ago by superm1@…

Upstream XFCE indicated that their API will not remain stable for using the dbus interface to xfce-session. Because of this, I've dropped their portion of the code and replaced it with consolekit. This has the added benefit that it will allow non Gnome/KDE/Xfce to be able to shutdown.

Changed 10 years ago by superm1@…

Attachment: use_session_ck_hal.diff added

comment:2 Changed 10 years ago by superm1@…

Although HAL is going away in the future, here's support for using all the different methods I can find for shutting down/rebooting. The logic will try each of these now in order:

1) KDE method 2) Gnome Method 3) ConsoleKit? 4) HAL 5) Halt Command

That should cover all major situations. HAL is currently pretty standard on distros, and consolekit if not already is will be standard.

comment:3 Changed 10 years ago by anonymous

Wouldn't "shutdown now" with the appropriate options be the best option? No need to complicate MythTV trying 20 different ways to do the same thing. Every application is coded to accept a kill signal...

comment:4 Changed 10 years ago by superm1@…

No, because that requires that you are running mythfrontend as root, or a user who has access to the shutdown command.

This way lets a lowly user do it.

comment:5 Changed 10 years ago by Stuart Auchterlonie

Milestone: unknown0.23

comment:6 Changed 10 years ago by JYA

Resolution: fixed
Status: newclosed

(In [23518]) When running under a managed session, use that session's tools to shutdown/reboot. Fix #7749. Patch from Mario Limonciello and the Mythbuntu team

comment:7 Changed 10 years ago by Nigel

Resolution: fixed
Status: closednew

Unfortunately, this breaks OS X and Windows builds. The hacky fix would be for configure to test if Qt was compiled with DBus support, and #ifdef HAVE_DBUS in exitprompt.cpp. The possibly better fix would be to see if there are any DBus interfaces on OS X and Windows to shutdown/restart, and if so to build libdbus or winDBus on those platforms.
I'm trying to build libdbus on OS X right now...

comment:8 Changed 10 years ago by JYA

I guess for the time being I will have something like: #ifdef HAVE_DBUS new code #else oldcode #endif

Changed 10 years ago by Nigel

Attachment: 7749-config.patch added

Something like this?

comment:9 Changed 10 years ago by Nigel

Rough, untested, patch atached.
It is possible that a user has built Qt --nodbus for some reason, so it is a config_ thing, not a HAVE_ ?
I think the .pro also needs a guard, because on Mac OS X, it tries to link in -lQtDBus - despite the fact that there is none and Qt was built without that feature.

comment:10 Changed 10 years ago by Nigel

(In [23559]) Test if Qt was built with DBus support. Refs #7749.

comment:11 Changed 10 years ago by Nigel

Resolution: fixed
Status: newclosed

(In [23560]) Only compile DBus shutdown/restart code if Qt supports it. Closes #7749. Only build tested on Linux/MacOS.

comment:12 Changed 10 years ago by chrisl

This change caused ticket #8160

comment:13 Changed 9 years ago by sphery

(In [25433]) Fixes #8291. Remove the default values for the "Reboot command" and "Halt command" settings.

The given values likely will not work on most systems without at least a sudo (and possibly path information), and including default values prevents dbus shutdown from working. Therefore, more systems are likely to just do the right thing without the default values. Users wanting to use a script can simply provide the appropriate command invocation (which is almost definitely different from the former default values). This change will only affect new setups, not existing setups. Refs #8160. Refs #7749.

Note: See TracTickets for help on using tickets.