diff options
Diffstat (limited to 'packages/host-bin/src/main.cpp')
| -rw-r--r-- | packages/host-bin/src/main.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/packages/host-bin/src/main.cpp b/packages/host-bin/src/main.cpp index 713186d..eb3892c 100644 --- a/packages/host-bin/src/main.cpp +++ b/packages/host-bin/src/main.cpp @@ -1,14 +1,39 @@ #include <unbox/kernel/kernel.hpp> +#include <unbox/kernel/server.hpp> #include <cstdio> +#include <exception> +#include <string_view> -auto main() -> int { - const bool probe_ok = unbox::kernel::link_probe(); +namespace { - std::printf("unbox 0.0.1 — kernel skeleton (slice 1)\n"); - std::printf(" wlroots %s\n", unbox::kernel::wlroots_version().c_str()); - std::printf(" RmlUi %s\n", unbox::kernel::rmlui_version().c_str()); - std::printf(" link probe %s\n", probe_ok ? "ok" : "FAILED"); +void print_usage(const char* argv0) { + std::printf("usage: %s [-s <startup command>]\n", argv0); +} + +} // namespace + +auto main(int argc, char* argv[]) -> int { + unbox::kernel::Server::Options options; + for (int i = 1; i < argc; ++i) { + const std::string_view arg = argv[i]; + if (arg == "-s" && i + 1 < argc) { + options.startup_cmd = argv[++i]; + } else { + print_usage(argv[0]); + return arg == "-h" ? 0 : 1; + } + } - return probe_ok ? 0 : 1; + try { + auto server = unbox::kernel::Server::create(std::move(options)); + std::printf("unbox 0.0.1 (wlroots %s, RmlUi %s) on WAYLAND_DISPLAY=%s\n", + unbox::kernel::wlroots_version().c_str(), + unbox::kernel::rmlui_version().c_str(), server->socket_name().c_str()); + server->run(); + } catch (const std::exception& e) { + std::fprintf(stderr, "unbox: fatal: %s\n", e.what()); + return 1; + } + return 0; } |
