aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorian2007-11-28 16:35:52 +0000
committerian2007-11-28 16:35:52 +0000
commit39193ce4f0d99ad8f16707e00590cb0831c3b2ea (patch)
tree539855d794aea6a6c341d16825df3c4be2d2d8cf
parent7f9f575b0ac9765c51c4ac7f61c23660576a5e22 (diff)
downloadcwm-39193ce4f0d99ad8f16707e00590cb0831c3b2ea.tar.gz
Add a "restart wm" function. ok oga@
-rw-r--r--calmwm.h6
-rw-r--r--conf.c6
-rw-r--r--cwm.18
-rw-r--r--kbfunc.c31
-rw-r--r--util.c18
5 files changed, 61 insertions, 8 deletions
diff --git a/calmwm.h b/calmwm.h
index 741feb5..075fc2f 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
* 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/conf.c b/conf.c
index 4681fae..1f2f318 100644
--- a/conf.c
+++ b/conf.c
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
* 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/cwm.1 b/cwm.1
index 57ac99a..3d98d7b 100644
--- a/cwm.1
+++ b/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/kbfunc.c b/kbfunc.c
index b748f60..d14f874 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Martin Murray <mmurray@monkey.org>
* 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 <paths.h>
@@ -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/util.c b/util.c
index 157783a..3b2ddbc 100644
--- a/util.c
+++ b/util.c
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
* All rights reserved.
*
- * $Id: util.c,v 1.1.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;