diff --git a/apps/init.cpp b/apps/init.cpp index f7e37013..b0c2c7d9 100644 --- a/apps/init.cpp +++ b/apps/init.cpp @@ -34,6 +34,7 @@ struct Service String standard_output; String standard_error; String standard_input; + String working_directory; Option user {}; Option group {}; bool wait { false }; @@ -85,6 +86,8 @@ static Result service_child(const Service& service, SharedPtr ou if (error) dup2(error->fd(), STDERR_FILENO); if (input) dup2(input->fd(), STDIN_FILENO); + if (!service.working_directory.is_empty()) chdir(service.working_directory.chars()); + if (service.user.has_value()) { setgid(service.group.value()); @@ -240,6 +243,12 @@ static Result load_service(const os::Path& path) continue; } + if (parts[0].view() == "WorkingDirectory") + { + service.working_directory = move(parts[1]); + continue; + } + if (g_is_system && parts[0].view() == "User") { auto* pw = getpwnam(parts[1].chars()); diff --git a/base/etc/user/00-taskbar b/base/etc/user/00-taskbar index 19614216..398940b9 100644 --- a/base/etc/user/00-taskbar +++ b/base/etc/user/00-taskbar @@ -1,4 +1,5 @@ Name=taskbar Description=Start the taskbar. Command=/usr/bin/taskbar +WorkingDirectory=/home/selene Restart=true diff --git a/base/etc/user/01-terminal b/base/etc/user/01-terminal index 2e93a0e6..c73e5fe1 100644 --- a/base/etc/user/01-terminal +++ b/base/etc/user/01-terminal @@ -1,3 +1,4 @@ Name=terminal Description=Start the terminal. +WorkingDirectory=/home/selene Command=/usr/bin/terminal