action: expand shell variables before execvp()

Expanding shell variables, including tilde, enables the following type
of keybind:

<keyboard>
    <keybind key="XF86AudioMute">
      <action name="Execute">
        <command>bash ~/mute-script.sh</command>
      </action>
    </keybind>
</keyboard>

Fixes issue #32
This commit is contained in:
Johan Malm 2021-06-30 19:56:31 +01:00
parent a1ae16c1cf
commit afe666fd6e
3 changed files with 60 additions and 4 deletions

View file

@ -26,7 +26,12 @@ action(struct server *server, const char *action, const char *command)
if (!strcasecmp(action, "Debug")) {
/* nothing */
} else if (!strcasecmp(action, "Execute")) {
spawn_async_no_shell(command);
struct buf cmd;
buf_init(&cmd);
buf_add(&cmd, command);
buf_expand_shell_variables(&cmd);
spawn_async_no_shell(cmd.buf);
free(cmd.buf);
} else if (!strcasecmp(action, "Exit")) {
wl_display_terminate(server->wl_display);
} else if (!strcasecmp(action, "NextWindow")) {