Commits

Anonymous committed 7ccdef0

rework config.def.h

Comments (0)

Files changed (2)

 /*
- * This defines the command to run when you join a new channel or a new message comes in.
- * Use paths[wd] for the path to the channel's directory, channel for the channel name
- * (actually it's "name> " so it can be used as a prompt for srw), out for the out file
- * and in for the in fifo. If you want to do something more complicated, write a script to
- * put in your path and execute. For example, I replace cw with a script that calls cw but
- * pipes the output through sed for colors and bell on my nick so urxvt sets the urgent hint.
+ * This defines the command to run when you join a new channel or a new message
+ * comes in. Use 'path' for the path to the channel's directory, 'channel' for
+ * the channel name, 'out' for the out file and 'in' for the in fifo. If you
+ * want to do something more complicated, write a script to put in your path and
+ * execute (as with cw_color.sh), or hack away in here.
  */
 
+void win_cmd(char *path, char *channel, char *out, char *in, char *nick)
+{
+	char prompt[32]; // sizeof(channel)
+	char *cmd[] = { "urxvt", "-title", path, "-e", "srw", "-p", prompt, "cw", out, in, NULL };
+
+	snprintf(prompt, sizeof(prompt), "%s> ", channel);
+
+	execvp(cmd[0], cmd);
+	err(1, "failed on execvp %s", cmd[0]);
+}
+
+
 /*
  * The default command
+ * char *cmd[] = { "urxvt", "-title", path, "-e", "srw", "-p", prompt, "cw", out, in, NULL };
+ *
+ * Use this if for some reason you really don't want to use srw, it's not
+ * necessary, but it makes everything much nicer, there's a reason, it's the
+ * default...
+ * char *cmd[] = { "urxvt", "-title", path, "-e", "cw", out, in, NULL };
+ *
+ *
+ * Use this if you want colors and bell on your nick. You can first edit
+ * cw_color.sh to change the nick if you don't want to use -n nick every time,
+ * then place it in your path. It is not installed by default.
+ * char *cmd[] = { "urxvt", "-title", path, "-e", "srw", "-p", prompt, "cw_color.sh", out, in, nick, NULL };
+ *
+ * Use this if you want to use tabbed (http://tools.suckless.org/tabbed) so
+ * that each new channel is it's own tab. Start tabbed with -d, then export the
+ * window id as pcw_window_id, then start pcw. It would be fairly simple to do
+ * all three steps in a script, have fun! (and you can add the color too if you
+ * want)
+ * char *cmd[] = { "urxvt", "-embed", getenv("pcw_window_id"), "-title", path, "-e", "srw", "-p", prompt, "cw", out, in, NULL };
  */
-#define CMD { "urxvt", "-title", w->path, "-e", "srw", "-p", channel, "cw", out, in, NULL }
-
-/*
- * Use this if for some reason you really don't want to use srw, it's not necessary, but it makes
- * everything much nicer, there's a reason, it's the default...
- */
-//#define CMD { "urxvt", "-title", w->path, "-e", "cw", out, in, NULL }
-
-
-/*
- * Use this if you want colors and bell on your nick. You can first edit cw_color.sh to change the
- * nick if you don't want to use -n nick every time, then place it in your path. It is not installed
- * by default.
- */
-//#define CMD { "urxvt", "-title", w->path, "-e", "srw", "-p", channel, "cw_color.sh", out, in, nick, NULL }
-
-/*
- * Use this if you want to use tabbed (http://tools.suckless.org/tabbed) so that each new channel is
- * it's own tab. Start tabbed with -d, then export the window id as pcw_window_id, then start pcw.
- * It would be fairly simple to do all three steps in a script, have fun! (and you can add the color
- * too if you want)
- */
-//#define CMD { "urxvt", "-embed", getenv("pcw_window_id"), "-title", w->path, "-e", "srw", "-p", channel, "cw", out, in, NULL }
 
 /* vim: set ts=4 sw=4 noexpandtab: */
 #include <sys/inotify.h>
 #include <sys/wait.h>
 
-#include "config.h" // for CMD
+#include "config.h" // for cmd
 
 // fairly arbitray values...feel free to change
 #define PATH_MAX    256
 {
 	int fd = 0;
 	char out[PATH_MAX], in[PATH_MAX], path[PATH_MAX], channel[32];
-	char *cmd[] = CMD; // from config.h
 
 	if (w->pid)
 		return;
 
 	close(fd);
 	strcpy(path, w->path); // stupid basename messing with my strings
-	snprintf(channel, sizeof(channel), "%s> ", basename(path));
+	strncpy(channel, basename(path), sizeof(channel));
 
-	if ((w->pid = fork()) == 0) {
-		execvp(cmd[0], cmd);
-		err(1, "failed on execvp %s", cmd[0]);
-	}
+	if ((w->pid = fork()) == 0)
+		win_cmd(w->path, channel, out, in, nick);
 }
 
 int main(int argc, char **argv)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.