mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Add a "restart wm" function. ok oga@
This commit is contained in:
parent
f14a3eeebf
commit
8b3cd2243a
4
calmwm.h
4
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
|
||||
|
||||
|
4
conf.c
4
conf.c
@ -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 },
|
||||
|
6
cwm.1
6
cwm.1
@ -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:
|
||||
|
27
kbfunc.c
27
kbfunc.c
@ -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)
|
||||
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);
|
||||
|
16
util.c
16
util.c
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user