#include #include #include #include #include #include #include #include #include static int run_shutdown_dialog(int argc, char** argv); int main(int argc, char** argv) { if (argc != 2) { printf("usage: SystemDialog \n"); return 0; } if (String(argv[1]) == "--shutdown") return run_shutdown_dialog(argc, argv); fprintf(stderr, "Unknown argument: %s\n", argv[1]); return 1; } int run_shutdown_dialog(int argc, char** argv) { GApplication app(argc, argv); { auto result = GMessageBox::show("Shut down Serenity?", "Confirm Shutdown", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel); if (result == GMessageBox::ExecOK) { dbg() << "OK"; int rc = execl("/bin/shutdown", "/bin/shutdown", "-n", nullptr); if (rc < 0) { perror("execl"); return 1; } } else { dbg() << "Cancel"; return 0; } } return app.exec(); }