Skip to content
Myr

xdg: add support for TryExec

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Handle similar to 'NoDisplay'. That is, keep the entry, but mark it as not visible. This ensures desktop file overrides, i.e. ~/.local/share/applications/foo.desktop correctly overrides /usr/share/applications/foo.desktop Closes #723

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 43caf1d · Browse files · 2 files+37 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+37 added−0 removed

  • other:+37 added−0 removed

2 files+37 added−0 removed

modified:CHANGELOG.md+2 added
38 unmodified lines
39* `--override` command line option, allowing you to override **all**40 options available in `fuzzel.ini` ([#759][759]).41* IME support, via the `text-input-unstable-v3` Wayland protocol42 ([#615][614]).43* Support for the `TryExec` key in `.desktop` files ([#723][723]).4445[759]: https://codeberg.org/dnkl/fuzzel/issues/75946[615]: https://codeberg.org/dnkl/fuzzel/issues/61547[723]: https://codeberg.org/dnkl/fuzzel/issues/723484950### Changed51
1173 unmodified lines
modified:xdg.c+35 added
61 unmodified lines
62 char *action_id;63};6465static bool66is_executable(const char *bin)67{68 if (bin[0] == '/')69 return access(bin, X_OK) == 0;7071 const char *path = getenv("PATH");72 if (path == NULL)73 return false;7475 char *copy = xstrdup(path);76 for (char *ctx = NULL, *p = strtok_r(copy, ":", &ctx);77 p != NULL;78 p = strtok_r(NULL, ":", &ctx))79 {80 char *full_path = xstrjoin3(p, "/", bin);81 bool ok = access(full_path, X_OK) == 0;82 free(full_path);8384 if (ok) {85 free(copy);86 return true;87 }88 }8990 free(copy);91 return false;92}9394static bool95filter_desktop_entry(const struct action *act, const char_list_t *desktops)96{97 /* If a matching entry is found in OnlyShowIn then the desktop file is98 * shown. If an entry is found in NotShowIn then the desktop file is not
200 unmodified lines
299 action->exec = xstrdup(value);300 action->wexec = ambstoc32(value);301 }302303 else if (strcmp(key, "TryExec") == 0) {304 if (!is_executable(value)) {305 action->visible = false;306 }307 }308309 else if (strcmp(key, "Path") == 0) {310 free(action->path);311 action->path = xstrdup(value);312 }
618 unmodified lines