Skip to content
Myr

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

3 files+17 added−1 removed

modified:application.h+1 added
1 unmodified line
23#include <cairo.h>45struct application {6 char *path;7 char *exec;8 char *title;9 char *comment;10 cairo_surface_t *icon;
1 unmodified line
modified:main.c+9 added
544 unmodified lines
545546 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;552553 LOG_DBG("exec(%s)", execute);554555 if (strchr(execute, '\\') != NULL) {
33 unmodified lines
589590 /* Close read end */591 close(pipe_fds[0]);592593 if (path != NULL) {594 if (chdir(path) == -1)595 LOG_ERRNO("failed to chdir to %s", path);596 }597598 /* 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 lines
1284 shm_fini();12851286 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 lines
modified:xdg.c+7 added-1 removed
102 unmodified lines
103104 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 lines
153154 else if (strcmp(key, "Exec") == 0)155 exec = strdup(value);156157 else if (strcmp(key, "Path") == 0)158 path = strdup(value);159160 else if (strcmp(key, "GenericName") == 0)161 generic_name = strdup(value);162163 else if (strcmp(key, "Icon") == 0)
23 unmodified lines
187 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 }198199 free(path);200 free(name);201 free(exec);202 free(generic_name);203 free(icon);
129 unmodified lines