From 9c7e3d61414a846c6b85d62f76177a30a255423a Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 29 Dec 2017 20:03:46 +0000 Subject: Convert menu-exec-wm from an abritrary exec menu, into a config-based menu from which one may configure (wm ) (and choose) specific window managers to replace the running one. 'wm cwm cwm' is included by default. No objections and seems sensible to sthen. --- conf.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 8267686..6d3e131 100644 --- a/conf.c +++ b/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.236 2017/12/19 14:30:53 okan Exp $ + * $OpenBSD: conf.c,v 1.237 2017/12/29 20:03:46 okan Exp $ */ #include @@ -193,10 +193,8 @@ static const struct { CWM_MENU_WINDOW_ALL }, { "menu-window-hidden", kbfunc_menu_client, CWM_CONTEXT_SC, CWM_MENU_WINDOW_HIDDEN }, - { "menu-exec", kbfunc_menu_exec, CWM_CONTEXT_SC, - CWM_MENU_EXEC_EXEC }, - { "menu-exec-wm", kbfunc_menu_exec, CWM_CONTEXT_SC, - CWM_MENU_EXEC_WM }, + { "menu-exec", kbfunc_menu_exec, CWM_CONTEXT_SC, 0 }, + { "menu-exec-wm", kbfunc_menu_wm, CWM_CONTEXT_SC, 0 }, { "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, 0 }, { "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, 0 }, @@ -298,6 +296,7 @@ conf_init(struct conf *c) TAILQ_INIT(&c->ignoreq); TAILQ_INIT(&c->cmdq); + TAILQ_INIT(&c->wmq); TAILQ_INIT(&c->keybindq); TAILQ_INIT(&c->autogroupq); TAILQ_INIT(&c->mousebindq); @@ -314,6 +313,8 @@ conf_init(struct conf *c) conf_cmd_add(c, "lock", "xlock"); conf_cmd_add(c, "term", "xterm"); + conf_wm_add(c, "cwm", "cwm"); + (void)snprintf(c->known_hosts, sizeof(c->known_hosts), "%s/%s", c->homedir, ".ssh/known_hosts"); @@ -327,7 +328,7 @@ conf_clear(struct conf *c) struct autogroup *ag; struct bind_ctx *kb, *mb; struct winname *wn; - struct cmd_ctx *cmd; + struct cmd_ctx *cmd, *wm; int i; while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) { @@ -335,6 +336,11 @@ conf_clear(struct conf *c) free(cmd->name); free(cmd); } + while ((wm = TAILQ_FIRST(&c->wmq)) != NULL) { + TAILQ_REMOVE(&c->wmq, wm, entry); + free(wm->name); + free(wm); + } while ((kb = TAILQ_FIRST(&c->keybindq)) != NULL) { TAILQ_REMOVE(&c->keybindq, kb, entry); free(kb); @@ -393,6 +399,23 @@ conf_cmd_remove(struct conf *c, const char *name) } } +int +conf_wm_add(struct conf *c, const char *name, const char *path) +{ + struct cmd_ctx *wm; + + wm = xmalloc(sizeof(*wm)); + wm->name = xstrdup(name); + if (strlcpy(wm->path, path, sizeof(wm->path)) >= sizeof(wm->path)) { + free(wm->name); + free(wm); + return(0); + } + + TAILQ_INSERT_TAIL(&c->wmq, wm, entry); + return(1); +} + void conf_autogroup(struct conf *c, int num, const char *name, const char *class) { -- cgit v1.2.3-2-gb3c3