diff --git a/USERGUIDE.md b/USERGUIDE.md index 3dbe67807..d06426107 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -721,11 +721,11 @@ Using this option, you can locate game images in the ROM directory tree. The ima Displays the framerate and VRAM statistics as an overlay. You normally never need to use this. **Note:** As of version 1.0.0 the VRAM usage statistics is not accurate; this issue will be addressed in future ES versions. -**Show "reboot system" menu entry** +**Show "reboot system" menu entry - Unix and Windows only** Gives the ability to hide the "Reboot system" entry on the quit menu. Anyone who has accidentally rebooted a system from such a menu will appreciate this. -**Show "power off system" menu entry** +**Show "power off system" menu entry - Unix and Windows only** Gives the ability to hide the "Power off system" entry on the quit menu. Anyone who has accidentally powered off a system from such a menu will appreciate this. @@ -743,11 +743,11 @@ The menu where you quit ES, or reboot or power off your system. If the option _"When to save metadata"_ has been set to _"On exit"_, the gamelist.xml files will be updated at this point. -**Reboot system** +**Reboot system - Unix and Windows only** Can be disabled, meaning the entry will not show up at all. -**Power off system** +**Power off system - Unix and Windows only** Can be disabled, meaning the entry will not show up at all. diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index c533e93dc..9bc7ee9b9 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -682,6 +682,9 @@ void GuiMenu::openOtherSettings() s->addSaveFunc([gpu_statistics] { Settings::getInstance()->setBool("DisplayGPUStatistics", gpu_statistics->getState()); }); + // macOS requires root privileges to reboot and power off so it doesn't make much + // sense to enable these settings and menu entries for this operating system. + #if !defined(__APPLE__) // Hide Reboot System option in the quit menu. auto show_rebootsystem = std::make_shared(mWindow); show_rebootsystem->setState(Settings::getInstance()->getBool("ShowRebootSystem")); @@ -695,6 +698,7 @@ void GuiMenu::openOtherSettings() s->addWithLabel("SHOW \"POWER OFF SYSTEM\" MENU ENTRY", show_poweroffsystem); s->addSaveFunc([show_poweroffsystem] { Settings::getInstance()->setBool("ShowPoweroffSystem", show_poweroffsystem->getState()); }); + #endif mWindow->pushGui(s); } @@ -732,6 +736,9 @@ void GuiMenu::openQuitMenu() } } + // macOS requires root privileges to reboot and power off so it doesn't make much + // sense to enable these settings and menu entries for this operating system. + #if !defined(__APPLE__) if (Settings::getInstance()->getBool("ShowRebootSystem")) { row.elements.clear(); row.makeAcceptInputHandler([window, this] { @@ -765,6 +772,7 @@ void GuiMenu::openQuitMenu() Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); s->addRow(row); } + #endif mWindow->pushGui(s); } diff --git a/es-core/src/Platform.cpp b/es-core/src/Platform.cpp index 63f701e1a..dccec8fbf 100644 --- a/es-core/src/Platform.cpp +++ b/es-core/src/Platform.cpp @@ -30,18 +30,24 @@ int runRebootCommand() { -#if defined(_WIN64) // Windows. +#if defined(_WIN64) return system("shutdown -r -t 0"); -#else // macOS and Linux. +#elif defined(__APPLE__) + // This will probably never be used as macOS requires root privileges to reboot. + return system("shutdown -r now"); +#else return system("shutdown --reboot now"); #endif } int runPoweroffCommand() { -#if defined(_WIN64) // Windows. +#if defined(_WIN64) return system("shutdown -s -t 0"); -#else // macOS and Linux. +#elif defined(__APPLE__) + // This will probably never be used as macOS requires root privileges to power off. + return system("shutdown now"); +#else return system("shutdown --poweroff now"); #endif } diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 172ca3be5..5f91b5403 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -205,8 +205,12 @@ void Settings::setDefaults() mBoolMap["ShowHiddenFiles"] = true; mBoolMap["ShowHiddenGames"] = true; mBoolMap["DisplayGPUStatistics"] = false; + // macOS requires root privileges to reboot and power off so it doesn't make much + // sense to enable these settings and menu entries for this operating system. + #if !defined(__APPLE__) mBoolMap["ShowRebootSystem"] = true; mBoolMap["ShowPoweroffSystem"] = true; + #endif // // Settings configured via command-line arguments.