# How to Specify Startup Applications When starting a compositor or display server, you usually want to start a few other applications. For example you might want to start a background viewer, a terminal, and a status bar. Doing so manually like what we've do would be immensely annoying, so let's add an option for users to specify startup apps. **Note**: [Write Your First Wayland Compositor](../write-your-first-wayland-compositor.md) is a prerequisite for this how-to. --- We'll start by creating an instance of `miral::ExternalClientLauncher`, this will provide a way to launch programs by name. Then, we'll create a function that will take the list of startup apps and launch them. Finally, we just need to pass the external client launcher and our configuration option to {func}`run_with` so that they're registered with the compositor. ```diff #include +#include +#include #include #include @@ -9,8 +10,22 @@ int main(int argc, char const* argv[]) { MirRunner runner{argc, argv}; + miral::ExternalClientLauncher external_client_launcher; + + auto run_startup_apps = [&](std::vector const& apps) + { + for(auto const& app : apps) + { + external_client_launcher.launch(std::vector{app}}); + } + }; + return runner.run_with( { - set_window_management_policy() + set_window_management_policy(), + external_client_launcher, + miral::ConfigurationOption{run_startup_apps, "startup-app", "App to run at startup (can be specified multiple times)"}, }); } ``` Now, to start `kgx` and `bomber` on startup, we can do: ```sh ./build/demo-mir-compositor --startup-app kgx --startup-app bomber ```