diff --git a/Userland/Libraries/LibDesktop/AppFile.cpp b/Userland/Libraries/LibDesktop/AppFile.cpp index 99f44f65ce0..0e33baf6f88 100644 --- a/Userland/Libraries/LibDesktop/AppFile.cpp +++ b/Userland/Libraries/LibDesktop/AppFile.cpp @@ -91,6 +91,12 @@ ByteString AppFile::executable() const return executable; } +Vector AppFile::arguments() const +{ + auto arguments = m_config->read_entry("App", "Arguments").trim_whitespace(); + return arguments.split(' '); +} + ByteString AppFile::description() const { return m_config->read_entry("App", "Description").trim_whitespace(); @@ -169,12 +175,20 @@ Vector AppFile::launcher_protocols() const return protocols; } -ErrorOr AppFile::spawn(ReadonlySpan arguments) const +ErrorOr AppFile::spawn(ReadonlySpan user_arguments) const { if (!is_valid()) return Error::from_string_literal("AppFile is invalid"); - TRY(Core::Process::spawn(executable(), arguments, working_directory())); + Vector args; + + auto arguments = AppFile::arguments(); + for (auto const& argument : arguments) + args.append(argument); + + args.extend(Vector(user_arguments)); + + TRY(Core::Process::spawn(executable(), args, working_directory())); return {}; } @@ -187,6 +201,10 @@ ErrorOr AppFile::spawn_with_escalation(ReadonlySpan user_argum Vector args; auto executable = AppFile::executable(); + auto arguments = AppFile::arguments(); + + for (auto const& argument : arguments) + args.append(argument); // FIXME: These single quotes won't be enough for executables with single quotes in their name. auto pls_with_executable = ByteString::formatted("/bin/pls '{}'", executable); diff --git a/Userland/Libraries/LibDesktop/AppFile.h b/Userland/Libraries/LibDesktop/AppFile.h index 10ed3265986..e1eb49d6671 100644 --- a/Userland/Libraries/LibDesktop/AppFile.h +++ b/Userland/Libraries/LibDesktop/AppFile.h @@ -33,6 +33,7 @@ public: ByteString name() const; ByteString menu_name() const; ByteString executable() const; + Vector arguments() const; ByteString category() const; ByteString description() const; ByteString working_directory() const;