Ticket #8160: use_user_shutdown_script.patch

File use_user_shutdown_script.patch, 1.6 KB (added by chrisl, 14 years ago)
  • programs/mythfrontend/exitprompt.cpp

     
    6262
    6363void ExitPrompter::halt()
    6464{
    65     if (!DBusHalt())
     65
     66    QString halt_cmd = gContext->GetSetting("HaltCommand","");
     67    if (!halt_cmd.isEmpty()) /* Use user specified command if it exists */
    6668    {
    67         QString halt_cmd = gContext->GetSetting("HaltCommand",
    68                                             "sudo /sbin/halt -p");
    69         if (!halt_cmd.isEmpty())
    70             myth_system(halt_cmd);
    71         else
    72             VERBOSE(VB_IMPORTANT, "Cannot halt - null command!");
     69        myth_system(halt_cmd);
     70    } else if (!DBusHalt()) /* If supported, use DBus to shutdown */
     71    {
     72        myth_system("sudo /sbin/halt -p");
    7373    }
     74
    7475}
    7576
    7677bool DBusReboot(void)
     
    117118
    118119void ExitPrompter::reboot()
    119120{
    120     if (!DBusReboot())
     121
     122    QString reboot_cmd = gContext->GetSetting("RebootCommand","");
     123    if (!reboot_cmd.isEmpty()) /* Use user specified command if it exists */
    121124    {
    122         QString reboot_cmd = gContext->GetSetting("RebootCommand",
    123                                               "sudo /sbin/reboot");
    124         if (!reboot_cmd.isEmpty())
    125             myth_system(reboot_cmd);
    126         else
    127             VERBOSE(VB_IMPORTANT, "Cannot reboot - null command!");
     125        myth_system(reboot_cmd);
     126    } else if (!DBusReboot()) /* If supported, use DBus to reboot */
     127    {
     128        myth_system("sudo /sbin/reboot");
    128129    }
     130
    129131}
    130132
    131133void ExitPrompter::handleExit()