Modify

Ticket #7749 (closed enhancement: fixed)

You must read the TicketHowTo before creating a new ticket or commenting on an existing ticket.

Opened 2 years ago

Last modified 19 months ago

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

Reported by: superm1@… Owned by: ijr
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

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

Change History

Changed 2 years ago by superm1@…

Changed 2 years ago by superm1@…

comment:1 Changed 2 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 2 years ago by superm1@…

comment:2 Changed 2 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 2 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 2 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 2 years ago by stuarta

  • Milestone changed from unknown to 0.23

comment:6 Changed 2 years ago by jyavenard

  • Status changed from new to closed
  • Resolution set to fixed

(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 2 years ago by nigel

  • Status changed from closed to new
  • Resolution fixed deleted

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 2 years ago by jyavenard

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

Changed 2 years ago by nigel

Something like this?

comment:9 Changed 2 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 2 years ago by nigel

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

comment:11 Changed 2 years ago by nigel

  • Status changed from new to closed
  • Resolution set to fixed

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

comment:12 Changed 23 months ago by chrisl

This change caused ticket #8160

comment:13 Changed 19 months ago by mdean

(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.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.