diff options
author | okan <okan> | 2017-12-29 20:03:46 +0000 |
---|---|---|
committer | okan <okan> | 2017-12-29 20:03:46 +0000 |
commit | 6e7dbf5bb71d56bb3443f57cb6b8707a291fe0d2 (patch) | |
tree | 6e842f14936d6a213a69c49587ce62cb92512925 /conf.c | |
parent | 43db5b55eaae67515ae926c0d195c1ef6aa4b607 (diff) | |
download | cwm-6e7dbf5bb71d56bb3443f57cb6b8707a291fe0d2.tar.gz cwm-6e7dbf5bb71d56bb3443f57cb6b8707a291fe0d2.tar.xz cwm-6e7dbf5bb71d56bb3443f57cb6b8707a291fe0d2.zip |
Convert menu-exec-wm from an abritrary exec menu, into a config-based menu from
which one may configure (wm <name> <path_and_args>) (and choose) specific window managers to replace the running one. 'wm cwm cwm' is included by default. No objections and seems sensible to sthen.
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/conf.c b/conf.c index 9668e94..9ef730f 100644 --- a/conf.c +++ b/conf.c @@ -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) { |