diff options
author | okan | 2017-12-29 20:03:46 +0000 |
---|---|---|
committer | okan | 2017-12-29 20:03:46 +0000 |
commit | 9c7e3d61414a846c6b85d62f76177a30a255423a (patch) | |
tree | aa15f6cb2dfac7e58c47e964f980385218b2ead3 /conf.c | |
parent | 94fa8f6008663944358afaeb58a1217cf564a95c (diff) | |
download | cwm-9c7e3d61414a846c6b85d62f76177a30a255423a.tar.gz |
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 '')
-rw-r--r-- | conf.c | 35 |
1 files changed, 29 insertions, 6 deletions
@@ -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 <sys/types.h> @@ -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) { |