main: chdir() to Path from .desktop file
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Daniel Eklöf · committed by Daniel Eklöf · parent 3183665 · Browse files · 3 files·+17 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+17 added−1 removed
- other:+17 added−1 removed
Provenance
- Commit
edca280- Tree
33572d7- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
3183665
3 files changed+17 added−1 removed
modified:application.h+1 added
1 unmodified line2 3 #include <cairo.h>4 5 struct application {6+ char *path;7 char *exec;8 char *title;9 char *comment;10 cairo_surface_t *icon;1 unmodified linemodified:main.c+9 added
544 unmodified lines545 546 const char *execute = c->match_count > 0547 ? c->matches[c->selected].application->exec548 : c->prompt.text;549+ const char *path = c->match_count > 0550+ ? c->matches[c->selected].application->path551+ : NULL;552 553 LOG_DBG("exec(%s)", execute);554 555 if (strchr(execute, '\\') != NULL) {33 unmodified lines589 590 /* Close read end */591 close(pipe_fds[0]);592 593+ if (path != NULL) {594+ if (chdir(path) == -1)595+ LOG_ERRNO("failed to chdir to %s", path);596+ }597+598 /* Redirect stdin/stdout/stderr -> /dev/null */599 int devnull_r = open("/dev/null", O_RDONLY | O_CLOEXEC);600 int devnull_w = open("/dev/null", O_WRONLY | O_CLOEXEC);601 682 unmodified lines1284 shm_fini();1285 1286 free(c.prompt.text);1287 tll_foreach(c.applications, it) {1288+ free(it->item.path);1289 free(it->item.exec);1290 free(it->item.title);1291 free(it->item.comment);1292 cairo_surface_destroy(it->item.icon);51 unmodified linesmodified:xdg.c+7 added-1 removed
102 unmodified lines103 104 bool is_desktop_entry = false;105 char *name = NULL;106 char *exec = NULL;107+ char *path = NULL;108 char *generic_name = NULL;109 char *icon = NULL;110 bool visible = true;111 41 unmodified lines153 154 else if (strcmp(key, "Exec") == 0)155 exec = strdup(value);156 157+ else if (strcmp(key, "Path") == 0)158+ path = strdup(value);159+160 else if (strcmp(key, "GenericName") == 0)161 generic_name = strdup(value);162 163 else if (strcmp(key, "Icon") == 0)23 unmodified lines187 if (!already_added) {188 tll_push_back(189 *applications,190 ((struct application){187- .exec = exec, .title = name, .comment = generic_name,191+ .path = path, .exec = exec, .title = name,192+ .comment = generic_name,193 .icon = load_icon(icon, icon_size, themes)}));194 free(icon);195 return;196 }197 }198 199+ free(path);200 free(name);201 free(exec);202 free(generic_name);203 free(icon);129 unmodified lines