apio
140910763e
All checks were successful
Build and test / build (push) Successful in 1m56s
Why are command-line utilities stored in "apps"? And why are apps like "editor" or "terminal" top-level directories? Command-line utilities now go in "utils". GUI stuff now goes in "gui". This includes: libui -> gui/libui, wind -> gui/wind, GUI apps -> gui/apps, editor&terminal -> gui/apps... System services go in "system".
36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
/**
|
|
* @file run.cpp
|
|
* @author apio (cloudapio.eu)
|
|
* @brief Tiny command-line utility to start a detached program in the current GUI session.
|
|
*
|
|
* @copyright Copyright (c) 2024, the Luna authors.
|
|
*
|
|
*/
|
|
|
|
#include <os/ArgumentParser.h>
|
|
#include <os/File.h>
|
|
#include <os/LocalClient.h>
|
|
#include <os/ipc/Launcher.h>
|
|
|
|
Result<int> luna_main(int argc, char** argv)
|
|
{
|
|
StringView program;
|
|
|
|
os::ArgumentParser parser;
|
|
parser.add_description("Start a detached program in the current GUI session."_sv);
|
|
parser.add_system_program_info("run"_sv);
|
|
parser.add_positional_argument(program, "program", true);
|
|
parser.parse(argc, argv);
|
|
|
|
OwnedPtr<os::IPC::Client> launcher_client = TRY(os::IPC::Client::connect("/tmp/launch.sock", false));
|
|
|
|
os::println("Requesting to start program '%s'...", program.chars());
|
|
|
|
os::Launcher::LaunchDetachedRequest request;
|
|
SET_IPC_STRING(request.command, program.chars());
|
|
request.search_in_path = true;
|
|
launcher_client->send_async(request);
|
|
|
|
return 0;
|
|
}
|