Add support for Path in .desktop files
This commit is contained in:
parent
48078ffb25
commit
d21507cd4b
4 changed files with 13 additions and 1 deletions
|
@ -110,7 +110,7 @@ void expand_exec(DesktopEntry *entry, const char *path)
|
||||||
|
|
||||||
gboolean read_desktop_file_full_path(const char *path, DesktopEntry *entry)
|
gboolean read_desktop_file_full_path(const char *path, DesktopEntry *entry)
|
||||||
{
|
{
|
||||||
entry->name = entry->generic_name = entry->icon = entry->exec = NULL;
|
entry->name = entry->generic_name = entry->icon = entry->exec = entry->cwd = NULL;
|
||||||
entry->hidden_from_menus = FALSE;
|
entry->hidden_from_menus = FALSE;
|
||||||
|
|
||||||
FILE *fp = fopen(path, "rt");
|
FILE *fp = fopen(path, "rt");
|
||||||
|
@ -185,6 +185,8 @@ gboolean read_desktop_file_full_path(const char *path, DesktopEntry *entry)
|
||||||
}
|
}
|
||||||
} else if (!entry->exec && strcmp(key, "Exec") == 0) {
|
} else if (!entry->exec && strcmp(key, "Exec") == 0) {
|
||||||
entry->exec = strdup(value);
|
entry->exec = strdup(value);
|
||||||
|
} else if (!entry->cwd && strcmp(key, "Path") == 0) {
|
||||||
|
entry->cwd = strdup(value);
|
||||||
} else if (!entry->icon && strcmp(key, "Icon") == 0) {
|
} else if (!entry->icon && strcmp(key, "Icon") == 0) {
|
||||||
entry->icon = strdup(value);
|
entry->icon = strdup(value);
|
||||||
} else if (strcmp(key, "NoDisplay") == 0) {
|
} else if (strcmp(key, "NoDisplay") == 0) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ typedef struct DesktopEntry {
|
||||||
char *exec;
|
char *exec;
|
||||||
char *icon;
|
char *icon;
|
||||||
char *path;
|
char *path;
|
||||||
|
char *cwd;
|
||||||
gboolean hidden_from_menus;
|
gboolean hidden_from_menus;
|
||||||
} DesktopEntry;
|
} DesktopEntry;
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,7 @@ void launcher_action(LauncherIcon *icon, XEvent *evt)
|
||||||
// Allow children to exist after parent destruction
|
// Allow children to exist after parent destruction
|
||||||
setsid();
|
setsid();
|
||||||
// Run the command
|
// Run the command
|
||||||
|
chdir(icon->cwd);
|
||||||
execl("/bin/sh", "/bin/sh", "-c", icon->cmd, NULL);
|
execl("/bin/sh", "/bin/sh", "-c", icon->cmd, NULL);
|
||||||
fprintf(stderr, "Failed to execlp %s\n", icon->cmd);
|
fprintf(stderr, "Failed to execlp %s\n", icon->cmd);
|
||||||
#if HAVE_SN
|
#if HAVE_SN
|
||||||
|
@ -507,6 +508,13 @@ void launcher_reload_icon(Launcher *launcher, LauncherIcon *launcherIcon)
|
||||||
if (launcherIcon->cmd)
|
if (launcherIcon->cmd)
|
||||||
free(launcherIcon->cmd);
|
free(launcherIcon->cmd);
|
||||||
launcherIcon->cmd = strdup(entry.exec);
|
launcherIcon->cmd = strdup(entry.exec);
|
||||||
|
if (launcherIcon->cwd)
|
||||||
|
free(launcherIcon->cwd);
|
||||||
|
if (entry.cwd) {
|
||||||
|
launcherIcon->cwd = strdup(entry.cwd);
|
||||||
|
} else {
|
||||||
|
launcherIcon->cwd = get_current_dir_name();
|
||||||
|
}
|
||||||
if (launcherIcon->icon_name)
|
if (launcherIcon->icon_name)
|
||||||
free(launcherIcon->icon_name);
|
free(launcherIcon->icon_name);
|
||||||
launcherIcon->icon_name = entry.icon ? strdup(entry.icon) : strdup(DEFAULT_ICON);
|
launcherIcon->icon_name = entry.icon ? strdup(entry.icon) : strdup(DEFAULT_ICON);
|
||||||
|
|
|
@ -28,6 +28,7 @@ typedef struct LauncherIcon {
|
||||||
Imlib_Image image_hover;
|
Imlib_Image image_hover;
|
||||||
Imlib_Image image_pressed;
|
Imlib_Image image_pressed;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
char *cwd;
|
||||||
char *icon_name;
|
char *icon_name;
|
||||||
char *icon_path;
|
char *icon_path;
|
||||||
char *icon_tooltip;
|
char *icon_tooltip;
|
||||||
|
|
Loading…
Reference in a new issue