diff options
author | emersion <contact@emersion.fr> | 2017-10-02 18:21:39 +0200 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-10-03 08:46:10 +0200 |
commit | eb0b315c6ca190cdc51d83b80405272ccbba45c0 (patch) | |
tree | 84e3e771435d161138441457fdda0639662a3875 /rootston | |
parent | c6866998173138d582a39a5ba59705fe1cb50b1a (diff) |
exec command if it's not exit
Diffstat (limited to 'rootston')
-rw-r--r-- | rootston/keyboard.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rootston/keyboard.c b/rootston/keyboard.c index d3f0bc67..5ac6e59b 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -1,6 +1,7 @@ #include <assert.h> #include <stdint.h> #include <stdlib.h> +#include <unistd.h> #include <wayland-server.h> #include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_pointer.h> @@ -25,6 +26,14 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard, struct roots_server *server = keyboard->input->server; if (strcmp(command, "exit") == 0) { wl_display_terminate(server->wl_display); + } else { + pid_t pid = fork(); + if (pid < 0) { + wlr_log(L_ERROR, "cannot execute binding command: fork() failed"); + return; + } else if (pid == 0) { + execl("/bin/sh", "/bin/sh", "-c", command, (void *)NULL); + } } } |