blob: 7d33ac5f8ee8c94264c06d22ef2a84e0a8e2fc52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#include "demo_ui.hpp"
#include <unbox/ext-keybindings/ext_keybindings.hpp>
#include <unbox/ext-layer-shell/ext_layer_shell.hpp>
#include <unbox/ext-stage-dock/ext_stage_dock.hpp>
#include <unbox/ext-xdg-shell/ext_xdg_shell.hpp>
#include <unbox/kernel/kernel.hpp>
#include <unbox/kernel/server.hpp>
#include <cstdio>
#include <exception>
#include <optional>
#include <string>
#include <string_view>
namespace {
void print_usage(const char* argv0) {
std::printf("usage: %s [-s <startup command>] [--config <path>] [--ui-demo]\n", argv0);
}
} // namespace
auto main(int argc, char* argv[]) -> int {
unbox::kernel::Server::Options options;
bool ui_demo = false;
std::optional<std::string> config_path;
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 if (arg == "--config" && i + 1 < argc) {
// Explicit unbox.toml for ext-keybindings; if omitted it discovers
// the XDG path, then falls back to compiled-in defaults.
config_path = argv[++i];
} else if (arg == "--ui-demo") {
// Slice-5 acceptance demo (temporary until the real UI extensions):
// a ui surface via the public substrate contract.
ui_demo = true;
} else {
print_usage(argv[0]);
return arg == "-h" ? 0 : 1;
}
}
try {
auto server = unbox::kernel::Server::create(std::move(options));
// The composition root: the ONLY place that names every extension.
// install() transfers ownership; run() activates in dependency order
// (ext-keybindings depends_on xdg-shell, resolved topologically).
server->install(unbox::ext_xdg_shell::create());
server->install(unbox::ext_layer_shell::create());
server->install(unbox::ext_keybindings::create(config_path));
// The stage dock: Super+M minimizes the focused window into a left-edge
// dock of previews; tap a preview to restore. Standard tier, hidden until
// it holds a minimized window (depends_on xdg-shell, topo-activated).
server->install(unbox::ext_stage_dock::create());
if (ui_demo) {
server->install(unbox::host_bin::create_demo_ui());
}
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;
}
|