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 /kbfunc.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-- | kbfunc.c | 60 |
1 files changed, 31 insertions, 29 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: kbfunc.c,v 1.158 2017/12/29 18:50:43 okan Exp $ + * $OpenBSD: kbfunc.c,v 1.159 2017/12/29 20:03:46 okan Exp $ */ #include <sys/types.h> @@ -546,6 +546,33 @@ kbfunc_menu_group(void *ctx, struct cargs *cargs) } void +kbfunc_menu_wm(void *ctx, struct cargs *cargs) +{ + struct screen_ctx *sc = ctx; + struct cmd_ctx *wm; + struct menu *mi; + struct menu_q menuq; + int mflags = 0; + + if (cargs->xev == CWM_XEV_BTN) + mflags |= CWM_MENU_LIST; + + TAILQ_INIT(&menuq); + TAILQ_FOREACH(wm, &Conf.wmq, entry) + menuq_add(&menuq, wm, NULL); + + if ((mi = menu_filter(sc, &menuq, "wm", NULL, mflags, + search_match_wm, search_print_wm)) != NULL) { + wm = (struct cmd_ctx *)mi->ctx; + free(Conf.wm_argv); + Conf.wm_argv = xstrdup(wm->path); + cwm_status = CWM_EXEC_WM; + } + + menuq_clear(&menuq); +} + +void kbfunc_menu_exec(void *ctx, struct cargs *cargs) { #define NPATHS 256 @@ -553,26 +580,13 @@ kbfunc_menu_exec(void *ctx, struct cargs *cargs) char **ap, *paths[NPATHS], *path, *pathcpy; char tpath[PATH_MAX]; struct stat sb; - const char *label; DIR *dirp; struct dirent *dp; struct menu *mi; struct menu_q menuq; - int l, i, cmd = cargs->flag; + int l, i; int mflags = (CWM_MENU_DUMMY | CWM_MENU_FILE); - switch (cmd) { - case CWM_MENU_EXEC_EXEC: - label = "exec"; - break; - case CWM_MENU_EXEC_WM: - label = "wm"; - break; - default: - errx(1, "%s: invalid cmd %d", __func__, cmd); - /* NOTREACHED */ - } - TAILQ_INIT(&menuq); if ((path = getenv("PATH")) == NULL) @@ -611,23 +625,11 @@ kbfunc_menu_exec(void *ctx, struct cargs *cargs) } free(path); - if ((mi = menu_filter(sc, &menuq, label, NULL, mflags, + if ((mi = menu_filter(sc, &menuq, "exec", NULL, mflags, search_match_exec, search_print_text)) != NULL) { if (mi->text[0] == '\0') goto out; - switch (cmd) { - case CWM_MENU_EXEC_EXEC: - u_spawn(mi->text); - break; - case CWM_MENU_EXEC_WM: - cwm_status = CWM_EXEC_WM; - free(Conf.wm_argv); - Conf.wm_argv = xstrdup(mi->text); - break; - default: - errx(1, "%s: egad, cmd changed value!", __func__); - /* NOTREACHED */ - } + u_spawn(mi->text); } out: if (mi != NULL && mi->dummy) |