diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2017-09-23 00:35:26 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2017-11-23 21:34:11 +0000 |
commit | 6d000e51014a2c34a510539ed9f4e8b9a0c8c059 (patch) | |
tree | 131200cfb524ca750a137af00704aa9ef9fbdbaf | |
parent | 4579df9114c00075166b59a67724ec7472facb27 (diff) | |
download | imv-6d000e51014a2c34a510539ed9f4e8b9a0c8c059.tar.gz |
Add exec command
-rw-r--r-- | src/imv.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -106,6 +106,7 @@ void command_zoom(struct imv_list *args, void *data); void command_remove(struct imv_list *args, void *data); void command_fullscreen(struct imv_list *args, void *data); void command_overlay(struct imv_list *args, void *data); +void command_exec(struct imv_list *args, void *data); static bool setup_window(struct imv *imv); static void handle_event(struct imv *imv, SDL_Event *event); @@ -151,6 +152,7 @@ struct imv *imv_create(void) imv_command_register(imv->commands, "remove", &command_remove); imv_command_register(imv->commands, "fullscreen", &command_fullscreen); imv_command_register(imv->commands, "overlay", &command_overlay); + imv_command_register(imv->commands, "exec", &command_exec); imv_command_alias(imv->commands, "q", "quit"); imv_command_alias(imv->commands, "next", "select_rel 1"); @@ -1035,4 +1037,19 @@ void command_overlay(struct imv_list *args, void *data) imv->need_redraw = true; } +void command_exec(struct imv_list *args, void *data) +{ + (void)data; + char *cmd = calloc(4096, 1); + for(size_t i = 0; i < args->len; ++i) { + strcat(cmd, args->items[i]); + + if(i + 1 != args->len) { + strcat(cmd, " "); + } + } + system(cmd); + free(cmd); +} + /* vim:set ts=2 sts=2 sw=2 et: */ |