summary refs log tree commit diff
path: root/util.c
diff options
context:
space:
mode:
authorokan <okan>2018-02-06 15:05:20 +0000
committerokan <okan>2018-02-06 15:05:20 +0000
commit63ebc0cd8b65300104929d3463fed431996f4374 (patch)
treef547800ff23c62896ad849d2148ec7adf3f08f0d /util.c
parenta0774f4777a4a94ea4bbc867c16cde3167075f80 (diff)
parentf3211427c16b755db20bc71ce4074e9fb9aae8af (diff)
downloadcwm-63ebc0cd8b65300104929d3463fed431996f4374.tar.gz
cwm-63ebc0cd8b65300104929d3463fed431996f4374.tar.xz
cwm-63ebc0cd8b65300104929d3463fed431996f4374.zip
cvsimport
* refs/heads/master: (28 commits)
  Use screen's saved view instead of re-querying the server.
  Slightly expand and expose verbose debugging.
  add debugging for x events
  Add a simple debug logging mechanism.
  Simplification; use asprintf where appropriate now.
  Use func attributes where appropriate.
  Fix wins comparison declaration since it's unsigned from XQueryTree().
  Generate name_to_func[] in a clean and readable fashion.
  Shrink tier[] by one after removing matchname in r1.55.
  If the requested group number is invalid, bail but don't kill cwm.
  Quick fix: exit after a failed execvp in u_spawn instead; previously we did in u_exec, but the introduction of re-exec'ing the previous invocation of cwm if 'exec_wm' failed missed the 'exec' failing path. Will likely split out as a proper fix.
  Only exec the fallback when in CWM_EXEC_WM state.
  Typo, from Julien Steinhauser.
  Convert menu-exec-wm from an abritrary exec menu, into a config-based menu from which one may configure (wm <name> <path_and_args>) (and choose) specific window managers to replace the running one. 'wm cwm cwm' is included by default.
  As done for buttonrelease, work specific un-cycling and un-highlighting actions into the keyrelease event, only performing what's actually needed for each; should result in much fewer events against keyreleases. No intended behaviour change.
  Merge group_toggle_membership_leave into the buttonrelease event and only do border work for a group/ungroup action.
  add helper function client_show to bring together like actions for unhide/raise
  Add support for re-exec'ing with SIGHUP; equivalent to the already built-in 'restart' function.
  Use poll and XNextEvent to replace XNextEvent blocking inside the x11 event handler.
  zap stray that snuck in
  ...
Diffstat (limited to 'util.c')
-rw-r--r--util.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/util.c b/util.c
index 7b8e4c8..9119cc2 100644
--- a/util.c
+++ b/util.c
@@ -31,13 +31,15 @@
 
 #include "calmwm.h"
 
+static void	 log_msg(const char *, va_list);
+
 void
 u_spawn(char *argstr)
 {
 	switch (fork()) {
 	case 0:
 		u_exec(argstr);
-		break;
+		exit(1);
 	case -1:
 		warn("fork");
 	default:
@@ -78,7 +80,7 @@ u_exec(char *argstr)
 
 	(void)setsid();
 	(void)execvp(args[0], args);
-	err(1, "%s", s);
+	warn("%s", s);
 }
 
 char *
@@ -104,3 +106,33 @@ u_argv(char * const *argv)
 	}
 	return(p);
 }
+
+static void
+log_msg(const char *msg, va_list ap)
+{
+	char	*fmt;
+
+	if (asprintf(&fmt, "%s\n", msg) == -1) {
+		vfprintf(stderr, msg, ap);
+		fprintf(stderr, "\n");
+	} else {
+		vfprintf(stderr, fmt, ap);
+		free(fmt);
+	}
+	fflush(stderr);
+}
+
+void
+log_debug(int level, const char *func, const char *msg, ...)
+{
+	char	*fmt;
+	va_list	 ap;
+
+	if (Conf.debug < level)
+		return;
+
+	va_start(ap, msg);
+	xasprintf(&fmt, "debug%d: %s: %s", level, func, msg);
+	log_msg(fmt, ap);
+	va_end(ap);
+}