From 3e7d91a55290733d8ea5de48f2fa9478c75221ee Mon Sep 17 00:00:00 2001 From: Ian Darwin Date: Wed, 28 Nov 2007 16:35:53 +0000 Subject: Add a "restart wm" function. ok oga@ --- app/cwm/calmwm.h | 6 +++++- app/cwm/conf.c | 6 ++++-- app/cwm/cwm.1 | 8 +++++++- app/cwm/kbfunc.c | 31 ++++++++++++++++++++++++++++--- app/cwm/util.c | 18 +++++++++++++++++- 5 files changed, 61 insertions(+), 8 deletions(-) (limited to 'app/cwm') diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 741feb519..075fc2f9a 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -4,7 +4,7 @@ * Copyright (c) 2004 Marius Aamodt Eriksen * All rights reserved. * - * $Id: calmwm.h,v 1.12 2007/11/19 22:18:16 oga Exp $ + * $Id: calmwm.h,v 1.13 2007/11/28 16:35:52 ian Exp $ */ #ifndef _CALMWM_H_ @@ -209,6 +209,10 @@ enum directions { CWM_UP=0, CWM_DOWN, CWM_LEFT, CWM_RIGHT, }; +/* for cwm_exec */ +#define CWM_EXEC_PROGRAM 0x1 +#define CWM_EXEC_WM 0x2 + #define KBFLAG_NEEDCLIENT 0x01 #define KBFLAG_FINDCLIENT 0x02 diff --git a/app/cwm/conf.c b/app/cwm/conf.c index 4681faeec..1f2f318b9 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -4,7 +4,7 @@ * Copyright (c) 2004 Marius Aamodt Eriksen * All rights reserved. * - * $Id: conf.c,v 1.15 2007/11/28 16:02:37 oga Exp $ + * $Id: conf.c,v 1.16 2007/11/28 16:35:52 ian Exp $ */ #include "headers.h" @@ -185,6 +185,7 @@ conf_setup(struct conf *c) conf_bindname(c, "CM-Return", "terminal"); conf_bindname(c, "CM-Delete", "lock"); conf_bindname(c, "M-question", "exec"); + conf_bindname(c, "CM-q", "exec_wm"); conf_bindname(c, "M-period", "ssh"); conf_bindname(c, "M-Return", "hide"); conf_bindname(c, "M-Down", "lower"); @@ -373,7 +374,8 @@ struct { { "prevgroup", kbfunc_client_prevgroup, 0, 0 }, { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 }, { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 }, - { "exec", kbfunc_exec, 0, 0 }, + { "exec", kbfunc_exec, 0, CWM_EXEC_PROGRAM }, + { "exec_wm", kbfunc_exec, 0, CWM_EXEC_WM }, { "ssh", kbfunc_ssh, 0, 0 }, { "terminal", kbfunc_term, 0, 0 }, { "lock", kbfunc_lock, 0, 0 }, diff --git a/app/cwm/cwm.1 b/app/cwm/cwm.1 index 57ac99a56..3d98d7bf1 100644 --- a/app/cwm/cwm.1 +++ b/app/cwm/cwm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwm.1,v 1.16 2007/11/19 22:18:16 oga Exp $ +.\" $OpenBSD: cwm.1,v 1.17 2007/11/28 16:35:52 ian Exp $ .\" .\" The following requests are required for all man pages. .Dd June 29, 2007 @@ -98,6 +98,12 @@ This parses to provide host auto-completion. .Xr ssh 1 will be executed via the configured terminal emulator. +.It Ic CM-q +Spawn +.Dq Exec WindowManager +dialog; allows you to switch from +.Nm +to another window manager without restarting the X server. .El .Pp The mouse bindings are also important, they are: diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index b748f605f..d14f87413 100644 --- a/app/cwm/kbfunc.c +++ b/app/cwm/kbfunc.c @@ -4,7 +4,7 @@ * Copyright (c) 2004 Martin Murray * All rights reserved. * - * $Id: kbfunc.c,v 1.10 2007/11/13 23:08:49 todd Exp $ + * $Id: kbfunc.c,v 1.11 2007/11/28 16:35:52 ian Exp $ */ #include @@ -263,6 +263,20 @@ kbfunc_exec(struct client_ctx *scratch, void *arg) struct stat sb; struct menu_q menuq; struct menu *mi; + char *label; + + int cmd = (int)arg; + switch(cmd) { + case CWM_EXEC_PROGRAM: + label = "exec"; + break; + case CWM_EXEC_WM: + label = "wm"; + break; + default: + err(1, "kbfunc_exec: invalid cmd %d", cmd); + /*NOTREACHED*/ + } if (getgroups(0, mygroups) == -1) err(1, "getgroups failure"); @@ -320,8 +334,19 @@ kbfunc_exec(struct client_ctx *scratch, void *arg) } if ((mi = search_start(&menuq, - search_match_exec, NULL, NULL, "exec", 1)) != NULL) - u_spawn(mi->text); + search_match_exec, NULL, NULL, label, 1)) != NULL) { + switch (cmd) { + case CWM_EXEC_PROGRAM: + u_spawn(mi->text); + break; + case CWM_EXEC_WM: + exec_wm(mi->text); + break; + default: + err(1, "kb_func: egad, cmd changed value!"); + break; + } + } if (mi != NULL && mi->dummy) xfree(mi); diff --git a/app/cwm/util.c b/app/cwm/util.c index 59a974cf1..3b2ddbccc 100644 --- a/app/cwm/util.c +++ b/app/cwm/util.c @@ -4,7 +4,7 @@ * Copyright (c) 2004 Marius Aamodt Eriksen * All rights reserved. * - * $Id: util.c,v 1.1 2007/04/27 17:58:48 bernd Exp $ + * $Id: util.c,v 1.2 2007/11/28 16:35:52 ian Exp $ */ #include "headers.h" @@ -39,6 +39,22 @@ u_spawn(char *argstr) return (0); } +void +exec_wm(char *argstr) +{ + char *args[MAXARGLEN], **ap = args; + char **end = &args[MAXARGLEN - 1]; + + while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL) + ap++; + + *ap = NULL; + setsid(); + execvp(args[0], args); + err(1, args[0]); +} + + int dirent_exists(char *filename) { struct stat buffer; -- cgit v1.2.3