Skip to content

Commit

Permalink
xdg-autostart: Add support for Path= in XDG Desktop File
Browse files Browse the repository at this point in the history
This sets the working directory of the application.
  • Loading branch information
Benjamin Berg committed Oct 8, 2020
1 parent ba28df7 commit a0088d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/xdg-autostart-generator/xdg-autostart-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,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},
Expand Down Expand Up @@ -606,6 +607,14 @@ 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);

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;
Expand Down
1 change: 1 addition & 0 deletions src/xdg-autostart-generator/xdg-autostart-service.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ typedef struct XdgAutostartService {

char *type; /* Purely as an assertion check */
char *exec_string;
char *working_directory;

char **only_show_in;
char **not_show_in;
Expand Down

0 comments on commit a0088d5

Please sign in to comment.