mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
no more hidden (and mysterious) config reloads and allow binding a key
to a config reload; CMS-r by default. ok oga@
This commit is contained in:
parent
8be175b175
commit
6ea4b1bd3b
2
calmwm.h
2
calmwm.h
@ -425,7 +425,6 @@ void conf_unbind(struct conf *, struct keybinding *);
|
||||
void conf_mousebind(struct conf *, char *, char *);
|
||||
void conf_mouseunbind(struct conf *, struct mousebinding *);
|
||||
void conf_grab_mouse(struct client_ctx *);
|
||||
int conf_changed(char *);
|
||||
void conf_reload(struct conf *);
|
||||
void conf_font(struct conf *);
|
||||
|
||||
@ -444,6 +443,7 @@ void kbfunc_client_nogroup(struct client_ctx *, void *);
|
||||
void kbfunc_client_grouptoggle(struct client_ctx *, void *);
|
||||
void kbfunc_client_maximize(struct client_ctx *, void *);
|
||||
void kbfunc_client_vmaximize(struct client_ctx *, void *);
|
||||
void kbfunc_reload(struct client_ctx *, void *);
|
||||
void kbfunc_quit_wm(struct client_ctx *, void *);
|
||||
void kbfunc_moveresize(struct client_ctx *, void *);
|
||||
void kbfunc_menu_search(struct client_ctx *, void *);
|
||||
|
22
conf.c
22
conf.c
@ -61,29 +61,9 @@ conf_font(struct conf *c)
|
||||
c->FontHeight = font_ascent() + font_descent() + 1;
|
||||
}
|
||||
|
||||
int
|
||||
conf_changed(char *path)
|
||||
{
|
||||
static struct timespec old_ts;
|
||||
struct stat sb;
|
||||
int changed;
|
||||
|
||||
/* If the file does not exist we pretend that nothing changed */
|
||||
if (stat(path, &sb) == -1 || !(sb.st_mode & S_IFREG))
|
||||
return (0);
|
||||
|
||||
changed = !timespeccmp(&sb.st_mtimespec, &old_ts, ==);
|
||||
old_ts = sb.st_mtimespec;
|
||||
|
||||
return (changed);
|
||||
}
|
||||
|
||||
void
|
||||
conf_reload(struct conf *c)
|
||||
{
|
||||
if (!conf_changed(c->conf_path))
|
||||
return;
|
||||
|
||||
if (parse_config(c->conf_path, c) == -1) {
|
||||
warnx("config file %s has errors, not reloading", c->conf_path);
|
||||
return;
|
||||
@ -132,6 +112,7 @@ conf_init(struct conf *c)
|
||||
conf_bindname(c, "CM-g", "grouptoggle");
|
||||
conf_bindname(c, "CM-f", "maximize");
|
||||
conf_bindname(c, "CM-equal", "vmaximize");
|
||||
conf_bindname(c, "CMS-r", "reload");
|
||||
conf_bindname(c, "CMS-q", "quit");
|
||||
|
||||
conf_bindname(c, "M-h", "moveleft");
|
||||
@ -254,6 +235,7 @@ struct {
|
||||
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, 0},
|
||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "reload", kbfunc_reload, 0, 0 },
|
||||
{ "quit", kbfunc_quit_wm, 0, 0 },
|
||||
{ "exec", kbfunc_exec, 0, (void *)CWM_EXEC_PROGRAM },
|
||||
{ "exec_wm", kbfunc_exec, 0, (void *)CWM_EXEC_WM },
|
||||
|
2
cwm.1
2
cwm.1
@ -112,6 +112,8 @@ Spawn
|
||||
dialog; allows you to switch from
|
||||
.Nm
|
||||
to another window manager without restarting the X server.
|
||||
.It Ic C-M-S-r
|
||||
Reload configuration.
|
||||
.It Ic C-M-S-q
|
||||
Quit cwm.
|
||||
.El
|
||||
|
2
cwmrc.5
2
cwmrc.5
@ -206,6 +206,8 @@ mousebind M-3 window_resize
|
||||
.Ed
|
||||
.Sh BIND COMMAND LIST
|
||||
.Bl -tag -width 18n -compact
|
||||
.It reload
|
||||
reload configuration
|
||||
.It quit
|
||||
quit
|
||||
.Xr cwm 1
|
||||
|
10
kbfunc.c
10
kbfunc.c
@ -168,7 +168,6 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
conf_reload(&Conf);
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||
XCALLOC(mi, struct menu);
|
||||
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||
@ -215,14 +214,12 @@ kbfunc_cmdexec(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
kbfunc_term(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
conf_reload(&Conf);
|
||||
u_spawn(Conf.termpath);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_lock(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
conf_reload(&Conf);
|
||||
u_spawn(Conf.lockpath);
|
||||
}
|
||||
|
||||
@ -393,7 +390,6 @@ kbfunc_ssh(struct client_ctx *scratch, void *arg)
|
||||
|
||||
if ((mi = menu_filter(&menuq, "ssh", NULL, 1,
|
||||
search_match_exec, NULL)) != NULL) {
|
||||
conf_reload(&Conf);
|
||||
l = snprintf(cmd, sizeof(cmd), "%s -e ssh %s", Conf.termpath,
|
||||
mi->text);
|
||||
if (l != -1 && l < sizeof(cmd))
|
||||
@ -482,3 +478,9 @@ kbfunc_quit_wm(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
_xev_quit = 1;
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_reload(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
conf_reload(&Conf);
|
||||
}
|
||||
|
@ -113,8 +113,6 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
|
||||
struct menu_q menuq;
|
||||
struct cmd *cmd;
|
||||
|
||||
conf_reload(&Conf);
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||
XCALLOC(mi, struct menu);
|
||||
|
Loading…
x
Reference in New Issue
Block a user