From 29b5ff79307138824186f5ff51222e7b2ca6197d Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Fri, 25 Aug 2017 17:55:58 -0700 Subject: [PATCH] Add toggle-start, to allow a key to be both start and end --- keynav.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/keynav.c b/keynav.c index ba9852d..a6ee77b 100644 --- a/keynav.c +++ b/keynav.c @@ -146,6 +146,7 @@ void cmd_daemonize(char *args); void cmd_doubleclick(char *args); void cmd_drag(char *args); void cmd_end(char *args); +void cmd_toggle_start(char *args); void cmd_grid(char *args); void cmd_grid_nav(char *args); void cmd_history_back(char *args); @@ -228,6 +229,7 @@ dispatch_t dispatch[] = { "sh", cmd_shell, "start", cmd_start, "end", cmd_end, + "toggle-start", cmd_toggle_start, "history-back", cmd_history_back, "quit", cmd_quit, "restart", cmd_restart, @@ -365,7 +367,7 @@ void addbinding(int keycode, int mods, char *commands) { keybinding->mods = mods; g_ptr_array_add(keybindings, keybinding); - if (!strncmp(commands, "start", 5)) { + if (!strncmp(commands, "start", 5) || !strncmp(commands, "toggle-start", 12)) { int i = 0; startkey_t *startkey = calloc(sizeof(startkey_t), 1); startkey->keycode = keycode; @@ -1017,6 +1019,14 @@ void cmd_end(char *args) { zone = 0; } +void cmd_toggle_start(char *args) { + if (ISACTIVE) { + cmd_end(args); + } else { + cmd_start(args); + } +} + void cmd_history_back(char *args) { if (!ISACTIVE) return;