[hackers] [lchat] change and fix colors || Jan Klemkow

2018-04-01 Thread git
commit c857fde6775979c260b7b56c5271efee089d7722
Author: Jan Klemkow 
AuthorDate: Tue Mar 13 17:52:18 2018 +0100
Commit: Jan Klemkow 
CommitDate: Wed Mar 14 00:02:59 2018 +0100

change and fix colors

diff --git a/filter/indent.c b/filter/indent.c
index aaf0327..b45727c 100644
--- a/filter/indent.c
+++ b/filter/indent.c
@@ -7,7 +7,7 @@
 #include 
 
 #define color1 34
-#define color2 36
+#define color2 33
 
 int
 main(void)
@@ -44,7 +44,8 @@ main(void)
 
/* print prompt */
/* HH:MM  t */
-   printf("\033[%dm%s %*s", color, timestr, 12,
+   // e[7;30;40m
+   printf("\033[1;%dm\033[K%s %*s", color, timestr, 12,
strcmp(nick, old_nick) == 0 ? "" : nick);
 
strlcpy(old_nick, nick, sizeof old_nick);
@@ -66,7 +67,7 @@ main(void)
fputs(word, stdout);
first = false;
}
-   fputs("\033[0m", stdout);   /* turn color off */
+   fputs("\033[0m\033[K", stdout); /* turn color off */
fflush(stdout);
}
 



[hackers] [lchat] add special color for bellmatch in text part of chat msg || Jan Klemkow

2018-04-01 Thread git
commit 84eec82dccf223861142f19ca57b410ba414c98a
Author: Jan Klemkow 
AuthorDate: Tue Mar 13 23:46:24 2018 +0100
Commit: Jan Klemkow 
CommitDate: Wed Mar 14 00:02:59 2018 +0100

add special color for bellmatch in text part of chat msg

diff --git a/Makefile b/Makefile
index f153483..c739777 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-include config.mk
+#include config.mk
 
 .PHONY: all install filter clean test
 
@@ -21,8 +21,8 @@ lchat.o: lchat.c
-o $@ lchat.c
 
 filter: filter/indent
-filter/indent: filter/indent.c
-   $(CC) $(CFLAGS) -o $@ filter/indent.c
+filter/indent: filter/indent.c util.o util.h
+   $(CC) $(CFLAGS) -o $@ filter/indent.c util.o
 
 sl_test.o: sl_test.c slackline.h
$(CC) $(CFLAGS) -c -o $@ sl_test.c
@@ -32,3 +32,6 @@ sl_test: sl_test.o slackline.o slackline.h
 
 slackline.o: slackline.c slackline.h
$(CC) -c $(CFLAGS) -o $@ slackline.c
+
+util.o: util.c util.h
+   $(CC) -c $(CFLAGS) -o $@ util.c
diff --git a/filter/indent.c b/filter/indent.c
index b45727c..24a3550 100644
--- a/filter/indent.c
+++ b/filter/indent.c
@@ -6,8 +6,11 @@
 #include 
 #include 
 
+#include "../util.h"
+
 #define color1 34
 #define color2 33
+#define color3 35
 
 int
 main(void)
@@ -19,6 +22,7 @@ main(void)
char *next, *nick, *word;
int cols = 80;  /* terminal width */
int color = color1;
+   char *bell_file = ".bellmatch";
 
while (fgets(buf, sizeof buf, stdin) != NULL) {
time_t time = strtol(buf, , 10);
@@ -42,6 +46,9 @@ main(void)
if (strcmp(nick, old_nick) != 0)
color = color == color1 ? color2 : color1;
 
+   if (access(bell_file, R_OK) == 0 && bell_match(next, bell_file))
+   color = color3;
+
/* print prompt */
/* HH:MM  t */
// e[7;30;40m
diff --git a/util.c b/util.c
new file mode 100644
index 000..bf6d9ca
--- /dev/null
+++ b/util.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2018 Jan Klemkow 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+bool
+bell_match(const char *str, const char *regex_file)
+{
+   FILE *fh = NULL;
+   char cmd[BUFSIZ];
+
+   if (access(regex_file, R_OK) == -1)
+   return true;
+
+   snprintf(cmd, sizeof cmd, "exec grep -qf %s", regex_file);
+
+   if ((fh = popen(cmd, "w")) == NULL)
+   err(EXIT_FAILURE, "popen");
+
+   if (fputs(str, fh) == EOF)
+   err(EXIT_FAILURE, "fputs");
+
+   if (pclose(fh) == 0)
+   return true;
+
+   return false;
+}
diff --git a/util.h b/util.h
new file mode 100644
index 000..c3851b0
--- /dev/null
+++ b/util.h
@@ -0,0 +1,6 @@
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+bool bell_match(const char *str, const char *regex_file);
+
+#endif



[hackers] [PATCH] [dwm] Make unset property fallback strings configurable

2018-04-01 Thread Eric Pruitt

Since the default rule matching does substring comparisons, using the
fixed string "broken" as a fallback value can complicate or make
unambiguous matching impossible, so this change makes various fallback
strings for unset properties configurable via config.h.
---
 config.def.h | 5 +
 dwm.c| 7 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git config.def.h config.def.h
index a9ac303..8dfc8b1 100644
--- config.def.h
+++ config.def.h
@@ -43,6 +43,11 @@ static const Layout layouts[] = {
 	{ "[M]",  monocle },
 };
 
+/* Fallback strings for unset window properties. */
+static const char unset_instance_fallback[] = "broken";
+static const char unset_class_fallback[] = "broken";
+static const char unset_name_fallback[] = "broken";
+
 /* key definitions */
 #define MODKEY Mod1Mask
 #define TAGKEYS(KEY,TAG) \
diff --git dwm.c dwm.c
index c98678d..9735e32 100644
--- dwm.c
+++ dwm.c
@@ -235,7 +235,6 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
 static void zoom(const Arg *arg);
 
 /* variables */
-static const char broken[] = "broken";
 static char stext[256];
 static int screen;
 static int sw, sh;   /* X display screen geometry width, height */
@@ -288,8 +287,8 @@ applyrules(Client *c)
 	c->isfloating = 0;
 	c->tags = 0;
 	XGetClassHint(dpy, c->win, );
-	class= ch.res_class ? ch.res_class : broken;
-	instance = ch.res_name  ? ch.res_name  : broken;
+	class= ch.res_class ? ch.res_class : unset_class_fallback;
+	instance = ch.res_name  ? ch.res_name  : unset_instance_fallback;
 
 	for (i = 0; i < LENGTH(rules); i++) {
 		r = [i];
@@ -1998,7 +1997,7 @@ updatetitle(Client *c)
 	if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
 		gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
 	if (c->name[0] == '\0') /* hack to mark broken clients */
-		strcpy(c->name, broken);
+		strcpy(c->name, unset_name_fallback);
 }
 
 void