mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 08:57:35 +00:00
LibDesktop+Taskbar: Add 'WorkingDirectory' property to app files
This commit is contained in:
parent
953520df49
commit
05e7b338ad
3 changed files with 13 additions and 3 deletions
|
@ -82,6 +82,11 @@ String AppFile::category() const
|
||||||
return m_config->read_entry("App", "Category").trim_whitespace();
|
return m_config->read_entry("App", "Category").trim_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String AppFile::working_directory() const
|
||||||
|
{
|
||||||
|
return m_config->read_entry("App", "WorkingDirectory").trim_whitespace();
|
||||||
|
}
|
||||||
|
|
||||||
String AppFile::icon_path() const
|
String AppFile::icon_path() const
|
||||||
{
|
{
|
||||||
return m_config->read_entry("App", "IconPath").trim_whitespace();
|
return m_config->read_entry("App", "IconPath").trim_whitespace();
|
||||||
|
@ -145,7 +150,7 @@ bool AppFile::spawn() const
|
||||||
if (!is_valid())
|
if (!is_valid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto pid = Core::Process::spawn(executable());
|
auto pid = Core::Process::spawn(executable(), Span<String const> {}, working_directory());
|
||||||
if (pid.is_error())
|
if (pid.is_error())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
String executable() const;
|
String executable() const;
|
||||||
String category() const;
|
String category() const;
|
||||||
String description() const;
|
String description() const;
|
||||||
|
String working_directory() const;
|
||||||
String icon_path() const;
|
String icon_path() const;
|
||||||
GUI::Icon icon() const;
|
GUI::Icon icon() const;
|
||||||
bool run_in_terminal() const;
|
bool run_in_terminal() const;
|
||||||
|
|
|
@ -88,6 +88,7 @@ struct AppMetadata {
|
||||||
String executable;
|
String executable;
|
||||||
String name;
|
String name;
|
||||||
String category;
|
String category;
|
||||||
|
String working_directory;
|
||||||
GUI::Icon icon;
|
GUI::Icon icon;
|
||||||
bool run_in_terminal;
|
bool run_in_terminal;
|
||||||
};
|
};
|
||||||
|
@ -104,7 +105,7 @@ ErrorOr<Vector<String>> discover_apps_and_categories()
|
||||||
HashTable<String> seen_app_categories;
|
HashTable<String> seen_app_categories;
|
||||||
Desktop::AppFile::for_each([&](auto af) {
|
Desktop::AppFile::for_each([&](auto af) {
|
||||||
if (access(af->executable().characters(), X_OK) == 0) {
|
if (access(af->executable().characters(), X_OK) == 0) {
|
||||||
g_apps.append({ af->executable(), af->name(), af->category(), af->icon(), af->run_in_terminal() });
|
g_apps.append({ af->executable(), af->name(), af->category(), af->working_directory(), af->icon(), af->run_in_terminal() });
|
||||||
seen_app_categories.set(af->category());
|
seen_app_categories.set(af->category());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -202,7 +203,10 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(WindowRefence& window_ref)
|
||||||
posix_spawn_file_actions_t spawn_actions;
|
posix_spawn_file_actions_t spawn_actions;
|
||||||
posix_spawn_file_actions_init(&spawn_actions);
|
posix_spawn_file_actions_init(&spawn_actions);
|
||||||
auto home_directory = Core::StandardPaths::home_directory();
|
auto home_directory = Core::StandardPaths::home_directory();
|
||||||
posix_spawn_file_actions_addchdir(&spawn_actions, home_directory.characters());
|
if (app.working_directory.is_empty())
|
||||||
|
posix_spawn_file_actions_addchdir(&spawn_actions, home_directory.characters());
|
||||||
|
else
|
||||||
|
posix_spawn_file_actions_addchdir(&spawn_actions, app.working_directory.characters());
|
||||||
|
|
||||||
pid_t child_pid;
|
pid_t child_pid;
|
||||||
if ((errno = posix_spawn(&child_pid, argv[0], &spawn_actions, nullptr, const_cast<char**>(argv), environ))) {
|
if ((errno = posix_spawn(&child_pid, argv[0], &spawn_actions, nullptr, const_cast<char**>(argv), environ))) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue