aboutsummaryrefslogtreecommitdiffstats
path: root/src/xdg-autostart-generator/xdg-autostart-service.c
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2020-10-08 15:58:08 +0200
committerBenjamin Berg <bberg@redhat.com>2020-10-09 11:04:19 +0200
commitd5273f51a1f452575eccfb855a8dc383c8d23f3a (patch)
tree0fc1ba56c5cbaa228905ac006da29b8582f5dea5 /src/xdg-autostart-generator/xdg-autostart-service.c
parentmissing-syscall: fix copypasta (diff)
downloadsystemd-d5273f51a1f452575eccfb855a8dc383c8d23f3a.tar.xz
systemd-d5273f51a1f452575eccfb855a8dc383c8d23f3a.zip
xdg-autostart: Add support for Path= in XDG Desktop File
This sets the working directory of the application.
Diffstat (limited to 'src/xdg-autostart-generator/xdg-autostart-service.c')
-rw-r--r--src/xdg-autostart-generator/xdg-autostart-service.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c
index 0485c90fc92..e111875b784 100644
--- a/src/xdg-autostart-generator/xdg-autostart-service.c
+++ b/src/xdg-autostart-generator/xdg-autostart-service.c
@@ -28,6 +28,7 @@ XdgAutostartService* xdg_autostart_service_free(XdgAutostartService *s) {
free(s->type);
free(s->exec_string);
+ free(s->working_directory);
strv_free(s->only_show_in);
strv_free(s->not_show_in);
@@ -321,6 +322,7 @@ XdgAutostartService *xdg_autostart_service_parse_desktop(const char *path) {
const ConfigTableItem items[] = {
{ "Desktop Entry", "Name", xdg_config_parse_string, 0, &service->description},
{ "Desktop Entry", "Exec", xdg_config_parse_string, 0, &service->exec_string},
+ { "Desktop Entry", "Path", xdg_config_parse_string, 0, &service->working_directory},
{ "Desktop Entry", "TryExec", xdg_config_parse_string, 0, &service->try_exec},
{ "Desktop Entry", "Type", xdg_config_parse_string, 0, &service->type},
{ "Desktop Entry", "OnlyShowIn", xdg_config_parse_strv, 0, &service->only_show_in},
@@ -606,6 +608,16 @@ int xdg_autostart_service_generate_unit(
"Slice=app.slice\n",
exec_start);
+ if (service->working_directory) {
+ _cleanup_free_ char *e_working_directory = NULL;
+
+ e_working_directory = cescape(service->working_directory);
+ if (!e_working_directory)
+ return log_oom();
+
+ fprintf(f, "WorkingDirectory=-%s\n", e_working_directory);
+ }
+
/* Generate an ExecCondition to check $XDG_CURRENT_DESKTOP */
if (!strv_isempty(service->only_show_in) || !strv_isempty(service->not_show_in)) {
_cleanup_free_ char *only_show_in = NULL, *not_show_in = NULL, *e_only_show_in = NULL, *e_not_show_in = NULL;