diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp index 84b75376a8c..ebaa1b5bce4 100644 --- a/Userland/Libraries/LibDesktop/Launcher.cpp +++ b/Userland/Libraries/LibDesktop/Launcher.cpp @@ -20,6 +20,11 @@ auto Launcher::Details::from_details_str(ByteString const& details_str) -> Nonnu auto const& obj = json.as_object(); details->executable = obj.get_byte_string("executable"sv).value_or({}); details->name = obj.get_byte_string("name"sv).value_or({}); + + obj.get_array("arguments"sv).value().for_each([&](JsonValue const& argument) { + details->arguments.append(argument.as_string()); + }); + if (auto type_value = obj.get_byte_string("type"sv); type_value.has_value()) { auto const& type_str = type_value.value(); if (type_str == "app") diff --git a/Userland/Libraries/LibDesktop/Launcher.h b/Userland/Libraries/LibDesktop/Launcher.h index 5de48012926..c7e445569d8 100644 --- a/Userland/Libraries/LibDesktop/Launcher.h +++ b/Userland/Libraries/LibDesktop/Launcher.h @@ -26,6 +26,7 @@ public: struct Details : public RefCounted
{ ByteString name; ByteString executable; + Vector arguments; LauncherType launcher_type { LauncherType::Default }; static NonnullRefPtr
from_details_str(ByteString const&); diff --git a/Userland/Services/LaunchServer/Launcher.cpp b/Userland/Services/LaunchServer/Launcher.cpp index d083aa04a42..ac3fbbee42c 100644 --- a/Userland/Services/LaunchServer/Launcher.cpp +++ b/Userland/Services/LaunchServer/Launcher.cpp @@ -50,6 +50,12 @@ ByteString Handler::to_details_str() const auto obj = MUST(JsonObjectSerializer<>::try_create(builder)); MUST(obj.add("executable"sv, executable)); MUST(obj.add("name"sv, name)); + + auto arguments = MUST(obj.add_array("arguments"sv)); + for (auto const& argument : this->arguments) + MUST(arguments.add(argument)); + MUST(arguments.finish()); + switch (handler_type) { case Type::Application: MUST(obj.add("type"sv, "app")); @@ -63,6 +69,7 @@ ByteString Handler::to_details_str() const default: break; } + MUST(obj.finish()); return builder.to_byte_string(); } @@ -84,6 +91,7 @@ void Launcher::load_handlers(ByteString const& af_dir) Desktop::AppFile::for_each([&](auto af) { auto app_name = af->name(); auto app_executable = af->executable(); + auto app_arguments = af->arguments(); HashTable mime_types; for (auto& mime_type : af->launcher_mime_types()) mime_types.set(mime_type); @@ -94,7 +102,7 @@ void Launcher::load_handlers(ByteString const& af_dir) for (auto& protocol : af->launcher_protocols()) protocols.set(protocol); if (access(app_executable.characters(), X_OK) == 0) - m_handlers.set(app_executable, { Handler::Type::Default, app_name, app_executable, mime_types, file_types, protocols }); + m_handlers.set(app_executable, { Handler::Type::Default, app_name, app_executable, move(app_arguments), mime_types, file_types, protocols }); }, af_dir); } diff --git a/Userland/Services/LaunchServer/Launcher.h b/Userland/Services/LaunchServer/Launcher.h index 7d3771f44f1..f80618c511c 100644 --- a/Userland/Services/LaunchServer/Launcher.h +++ b/Userland/Services/LaunchServer/Launcher.h @@ -24,6 +24,7 @@ struct Handler { Type handler_type; ByteString name; ByteString executable; + Vector arguments; HashTable mime_types {}; HashTable file_types {}; HashTable protocols {};