mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Move termpath and lockpath into cmdq; side effect is that 'lock' and
'term' now show up in the application menu.
This commit is contained in:
2
calmwm.h
2
calmwm.h
@@ -294,8 +294,6 @@ struct conf {
|
|||||||
int snapdist;
|
int snapdist;
|
||||||
struct gap gap;
|
struct gap gap;
|
||||||
char *color[CWM_COLOR_NITEMS];
|
char *color[CWM_COLOR_NITEMS];
|
||||||
char termpath[MAXPATHLEN];
|
|
||||||
char lockpath[MAXPATHLEN];
|
|
||||||
char known_hosts[MAXPATHLEN];
|
char known_hosts[MAXPATHLEN];
|
||||||
#define CONF_FONT "sans-serif:pixelsize=14:bold"
|
#define CONF_FONT "sans-serif:pixelsize=14:bold"
|
||||||
char *font;
|
char *font;
|
||||||
|
|||||||
26
conf.c
26
conf.c
@@ -41,27 +41,19 @@ conf_cmd_add(struct conf *c, const char *name, const char *path)
|
|||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
|
|
||||||
/* "term" and "lock" have special meanings. */
|
|
||||||
if (strcmp(name, "term") == 0) {
|
|
||||||
if (strlcpy(c->termpath, path, sizeof(c->termpath)) >=
|
|
||||||
sizeof(c->termpath))
|
|
||||||
return (0);
|
|
||||||
} else if (strcmp(name, "lock") == 0) {
|
|
||||||
if (strlcpy(c->lockpath, path, sizeof(c->lockpath)) >=
|
|
||||||
sizeof(c->lockpath))
|
|
||||||
return (0);
|
|
||||||
} else {
|
|
||||||
conf_cmd_remove(c, name);
|
|
||||||
|
|
||||||
cmd = xmalloc(sizeof(*cmd));
|
cmd = xmalloc(sizeof(*cmd));
|
||||||
|
|
||||||
cmd->name = xstrdup(name);
|
cmd->name = xstrdup(name);
|
||||||
if (strlcpy(cmd->path, path, sizeof(cmd->path)) >=
|
if (strlcpy(cmd->path, path, sizeof(cmd->path)) >= sizeof(cmd->path)) {
|
||||||
sizeof(cmd->path))
|
free(cmd->name);
|
||||||
return (0);
|
free(cmd);
|
||||||
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
return(0);
|
||||||
}
|
}
|
||||||
return (1);
|
|
||||||
|
conf_cmd_remove(c, name);
|
||||||
|
|
||||||
|
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
||||||
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
19
kbfunc.c
19
kbfunc.c
@@ -213,13 +213,21 @@ kbfunc_cmdexec(struct client_ctx *cc, union arg *arg)
|
|||||||
void
|
void
|
||||||
kbfunc_term(struct client_ctx *cc, union arg *arg)
|
kbfunc_term(struct client_ctx *cc, union arg *arg)
|
||||||
{
|
{
|
||||||
u_spawn(Conf.termpath);
|
struct cmd *cmd;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry)
|
||||||
|
if (strcmp(cmd->name, "term") == 0)
|
||||||
|
u_spawn(cmd->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_lock(struct client_ctx *cc, union arg *arg)
|
kbfunc_lock(struct client_ctx *cc, union arg *arg)
|
||||||
{
|
{
|
||||||
u_spawn(Conf.lockpath);
|
struct cmd *cmd;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry)
|
||||||
|
if (strcmp(cmd->name, "lock") == 0)
|
||||||
|
u_spawn(cmd->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -309,6 +317,7 @@ void
|
|||||||
kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
|
struct cmd *cmdq;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@@ -323,6 +332,10 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cmdq, &Conf.cmdq, entry)
|
||||||
|
if (strcmp(cmdq->name, "term") == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
|
|
||||||
lbuf = NULL;
|
lbuf = NULL;
|
||||||
@@ -356,7 +369,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
|||||||
if (mi->text[0] == '\0')
|
if (mi->text[0] == '\0')
|
||||||
goto out;
|
goto out;
|
||||||
l = snprintf(cmd, sizeof(cmd), "%s -T '[ssh] %s' -e ssh %s",
|
l = snprintf(cmd, sizeof(cmd), "%s -T '[ssh] %s' -e ssh %s",
|
||||||
Conf.termpath, mi->text, mi->text);
|
cmdq->path, mi->text, mi->text);
|
||||||
if (l != -1 && l < sizeof(cmd))
|
if (l != -1 && l < sizeof(cmd))
|
||||||
u_spawn(cmd);
|
u_spawn(cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user