From 017135b44e91b0d9527e8f56212647c49a6faaf7 Mon Sep 17 00:00:00 2001 From: RasmusNylander <43042651+rasmusnylander@users.noreply.github.com> Date: Thu, 16 Dec 2021 14:20:25 +0100 Subject: [PATCH] KeyboardMapper: Port to LibMain --- .../KeyboardMapper/CMakeLists.txt | 2 +- Userland/Applications/KeyboardMapper/main.cpp | 24 +++++++------------ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Userland/Applications/KeyboardMapper/CMakeLists.txt b/Userland/Applications/KeyboardMapper/CMakeLists.txt index 79b69ef815..d85a7d8dbe 100644 --- a/Userland/Applications/KeyboardMapper/CMakeLists.txt +++ b/Userland/Applications/KeyboardMapper/CMakeLists.txt @@ -11,4 +11,4 @@ set(SOURCES ) serenity_app(KeyboardMapper ICON app-keyboard-mapper) -target_link_libraries(KeyboardMapper LibGUI LibKeyboard) +target_link_libraries(KeyboardMapper LibGUI LibKeyboard LibMain) diff --git a/Userland/Applications/KeyboardMapper/main.cpp b/Userland/Applications/KeyboardMapper/main.cpp index bd418542fd..ef8b59521b 100644 --- a/Userland/Applications/KeyboardMapper/main.cpp +++ b/Userland/Applications/KeyboardMapper/main.cpp @@ -6,32 +6,27 @@ #include "KeyboardMapperWidget.h" #include +#include #include #include #include #include #include #include -#include +#include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { const char* path = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(path, "Keyboard character mapping file.", "file", Core::ArgsParser::Required::No); - args_parser.parse(argc, argv); + args_parser.parse(arguments); - if (pledge("stdio getkeymap thread rpath cpath wpath recvfd sendfd unix", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio getkeymap thread rpath cpath wpath recvfd sendfd unix")); - auto app = GUI::Application::construct(argc, argv); + auto app = GUI::Application::construct(arguments.argc, arguments.argv); - if (pledge("stdio getkeymap thread rpath cpath wpath recvfd sendfd", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio getkeymap thread rpath cpath wpath recvfd sendfd")); auto app_icon = GUI::Icon::default_icon("app-keyboard-mapper"); @@ -49,10 +44,7 @@ int main(int argc, char** argv) keyboard_mapper_widget->load_from_system(); } - if (pledge("stdio thread rpath cpath wpath recvfd sendfd", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio thread rpath cpath wpath recvfd sendfd")); auto open_action = GUI::CommonActions::make_open_action( [&](auto&) {