summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2008-07-11 15:18:29 +0000
committerokan <okan>2008-07-11 15:18:29 +0000
commit6ea4b1bd3b3f6106a61e4fbb98a267f86a32261f (patch)
treee459581324620e4da3537abd0dc610d6200beb42
parent8be175b175f04c4c16ec4be63bab6b1d2b0ebbfd (diff)
downloadcwm-6ea4b1bd3b3f6106a61e4fbb98a267f86a32261f.tar.gz
cwm-6ea4b1bd3b3f6106a61e4fbb98a267f86a32261f.tar.xz
cwm-6ea4b1bd3b3f6106a61e4fbb98a267f86a32261f.zip
no more hidden (and mysterious) config reloads and allow binding a key
to a config reload; CMS-r by default.

ok oga@
-rw-r--r--calmwm.h2
-rw-r--r--conf.c22
-rw-r--r--cwm.12
-rw-r--r--cwmrc.52
-rw-r--r--kbfunc.c10
-rw-r--r--mousefunc.c2
6 files changed, 13 insertions, 27 deletions
diff --git a/calmwm.h b/calmwm.h
index 3f82c70..abdc84a 100644
--- a/calmwm.h
+++ b/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 *);
diff --git a/conf.c b/conf.c
index 10d891a..b824c4f 100644
--- a/conf.c
+++ b/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 },
diff --git a/cwm.1 b/cwm.1
index 55c66d6..0fa6d55 100644
--- a/cwm.1
+++ b/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
diff --git a/cwmrc.5 b/cwmrc.5
index e0b4f08..48b680e 100644
--- a/cwmrc.5
+++ b/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
diff --git a/kbfunc.c b/kbfunc.c
index e52d7e5..c836f6f 100644
--- a/kbfunc.c
+++ b/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);
+}
diff --git a/mousefunc.c b/mousefunc.c
index e7efacd..24d5414 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -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);