Re: [dev] slock: anti OOM killer - proper priv dropping - etc.

2013-07-28 Thread Anselm R Garbe
On 26 July 2013 00:46, Joerg Jung m...@umaxx.net wrote:
 Am 23.07.2013 um 15:50 schrieb Robert Schneider ziggoma...@outlook.com:
 I think this unportable and totally linux specific,
 hence shoul be in an ifdef linux or something.

If Robert provides the patch with ifdef __linux__ specificness, I
might consider adding it. Linux is probably the 90% platform these
days of our software, so it'd be fair to increase the slock robustness
on this platform.

Best regards,
Anselm



Re: [dev] Issue with DWM and x-terminal-emulator launching

2013-07-28 Thread Anselm R Garbe
On 27 July 2013 15:29, James Latteier jameslatte...@gmail.com wrote:
 This isn't related to fonts per se. When I launch st using the mod-key
 shortcut the system will freeze when killing X. This doesn't happen with
 another terminal emulator or when launching st from dmenu. I haven't
 seen this reported elsewhere but one other person on the arch forum
 has the same problem.

Well this must be related to how dwm forks and how st deals with dwm's approach.

I think this is an st issue that needs to be investigated.

Is this arch-specific or has this also been observed on other
64bit(-only?) lunix distros?

Best regards,
Anselm



Re: [dev] Issue with DWM and x-terminal-emulator launching

2013-07-28 Thread Anselm R Garbe
On 28 July 2013 09:51, Anselm R Garbe garb...@gmail.com wrote:
 On 27 July 2013 15:29, James Latteier jameslatte...@gmail.com wrote:
 This isn't related to fonts per se. When I launch st using the mod-key
 shortcut the system will freeze when killing X. This doesn't happen with
 another terminal emulator or when launching st from dmenu. I haven't
 seen this reported elsewhere but one other person on the arch forum
 has the same problem.

 Well this must be related to how dwm forks and how st deals with dwm's 
 approach.

 I think this is an st issue that needs to be investigated.

 Is this arch-specific or has this also been observed on other
 64bit(-only?) lunix distros?

A remark, a quick workaround would be:

static const char *termcmd[]  = { /bin/sh, -c, st, NULL };

Though haven't tested this...

Best regards,
Anselm



Re: [dev] [dwm] Hide unused tags

2013-07-28 Thread Anselm R Garbe
On 29 May 2013 14:23, Thuban thu...@singularity.fr wrote:
 Le 12:16:05 le 29/05.2013 , Uli Armbruster a écrit :
 Attached

 Thanks!
 Can I add it on the wiki?

Did you add it?

I don't see it at http://dwm.suckless.org/patches/

Best regards,
Anselm



Re: [dev] [dwm] [patch] Pulling to the master area on toggleview

2013-07-28 Thread Anselm R Garbe
On 23 May 2013 20:31, Raziel23 veno...@runbox.com wrote:
 I want to submit a patch which changes the toggleview function
 behaviour. When I pull a tag (and an assigned client to it) by using
 the toggleview function there is a good chance that I want it to be in
 focus. Here is the patch which will pull to the master area and focus
 the first client from the newly pulled tag. Now pulling tags become much
 more enjoyable.

The original behaviour was on purpose, however I do encourage you to
add this to the patches section in the wiki.

Best regards,
Anselm



[dev] Re: Issue with DWM and x-terminal-emulator launching

2013-07-28 Thread James Latteier
Anselm R Garbe garbeam at gmail.com writes:

 
 On 28 July 2013 09:51, Anselm R Garbe garbeam at gmail.com wrote:
  On 27 July 2013 15:29, James Latteier jameslatteier at gmail.com wrote:
  This isn't related to fonts per se. When I launch st using the mod-key
  shortcut the system will freeze when killing X. This doesn't happen with
  another terminal emulator or when launching st from dmenu. I haven't
  seen this reported elsewhere but one other person on the arch forum
  has the same problem.
 
  Well this must be related to how dwm forks and how st deals with dwm's 
 approach.
 
  I think this is an st issue that needs to be investigated.
 
  Is this arch-specific or has this also been observed on other
  64bit(-only?) lunix distros?
 
 A remark, a quick workaround would be:
 
 static const char *termcmd[]  = { /bin/sh, -c, st, NULL };
 
 Though haven't tested this...
 
 Best regards,
 Anselm
 
I tried your *termcmd[] patch and it didn't fix the problem for me.

Just for the record I'm using an up-to-date archlinux distro with a
single-core 64-bit atom processor and a 3.10 kernel, current dwm-git
and st-git. The other case I know of is also archlinux, on an Inspiron
core-i5 processor, dwm 6.0 and st-git.

-James





Re: [dev] Wayland st!!??

2013-07-28 Thread Carlos Torres
Hi Michael.

On Sun, Jul 28, 2013 at 1:43 AM, Michael Forney mfor...@mforney.org wrote:
 On Sat, 27 Jul 2013 14:17:42 -0400, Carlos Torres vlaadbr...@gmail.com 
 wrote:
 I didn't know about this

 http://www.phoronix.com/scan.php?page=news_itempx=MTQyMTQ

 I'm both excited or looking to troll

 I'm the author of the port.

I'm glad you were the first to answer, Kudos. wayland needs more
suckless.  Keep on it and ignore the negative commentary. :-)

 I'm not sure how the suckless community
 feels about Wayland, but it seems like the core protocol is fairly
 lightweight, depends only on libffi, and is refreshing to work with
 compared to X.

you'll get varied reactions on the list.  I for one am happy to see
the mingling between wayland and suckless stuff, since it potentially
exposes the suckless philosophy, whatever it may be.

 Weston's goals are perhaps more orthogonal to suckless,
 but I think there is potential for a suckless compositor.

 I don't really expect there to be a suckless Wayland environment for a
 while, and maybe something better will come around before there is, but
 I think my rendering library could be useful in either case (the Wayland
 part is just buffer creation/management and is separate from the
 rendering part).

 --
 Michael Forney mfor...@mforney.org


Thanks
--Carlos



RE: [dev] slock: anti OOM killer - proper priv dropping - etc.

2013-07-28 Thread Robert Schneider
 If Robert provides the patch with ifdef __linux__ specificness, I
 might consider adding it.

Here's the ifdef'ed patch.
-- 
ziggomatic

1_dontkillme_v3.patch
Description: Binary data


Re: [dev] [dwm] Hide unused tags

2013-07-28 Thread Thuban
 Did you add it?

No, I didn't, I was waiting for an answer from the author, and then I
was busy somewhere else and didn't ask again.

Best regards,

Xavier



signature.asc
Description: Digital signature


Re: [dev] daemon for DWM

2013-07-28 Thread Markus Teich

Am 2013-07-27 18:27, schrieb Martti Kühne:

On Mon, Jul 22, 2013 at 3:17 PM, Markus Teich
markus.te...@stusta.mhn.de wrote:


rx_now=0
tx_now=0
for i in /sys/class/net/*; do
if [[ -d $i  ${i##*/} != lo ]]; then
if [[ -f $i/statistics/rx_bytes ]]; then
rx_now=($rx_now+`cat $i/statistics/rx_bytes`)
fi
if [[ -f $i/statistics/tx_bytes ]]; then
tx_now=($tx_now+`cat $i/statistics/tx_bytes`)
fi
fi
done
let rx_rate=($rx_now-$rx_old)
let tx_rate=($tx_now-$tx_old)


Might I ask what shell dialect is that written in? O_o


Bash patched together with some stackoverflow answers.
It probably is not beautiful, but it works for me until I finally have
the time to write it in C. :/

--Markus



Re: [dev] [sbase] Problem tar archiving the output file

2013-07-28 Thread Galos, David
 Attached diff also checks st_dev, which ought to cover all cases.
 Good catch, I will apply this tonight.
The patch has been applied.



Re: [dev] daemon for DWM

2013-07-28 Thread Silvan Jegen
On Sun, Jul 28, 2013 at 06:11:39PM +0200, Markus Teich wrote:
 Am 2013-07-27 18:27, schrieb Martti Kühne:
 On Mon, Jul 22, 2013 at 3:17 PM, Markus Teich
 markus.te...@stusta.mhn.de wrote:
 
 rx_now=0
 tx_now=0
 for i in /sys/class/net/*; do
 if [[ -d $i  ${i##*/} != lo ]]; then
 if [[ -f $i/statistics/rx_bytes ]]; then
 rx_now=($rx_now+`cat $i/statistics/rx_bytes`)
 fi
 if [[ -f $i/statistics/tx_bytes ]]; then
 tx_now=($tx_now+`cat $i/statistics/tx_bytes`)
 fi
 fi
 done
 let rx_rate=($rx_now-$rx_old)
 let tx_rate=($tx_now-$tx_old)
 
 Might I ask what shell dialect is that written in? O_o
 
 Bash patched together with some stackoverflow answers.
 It probably is not beautiful, but it works for me until I finally have
 the time to write it in C. :/

I included some changes suggested by Markus in a rewrite of the netusage
functions for dwmstatus (attached; including an adapted dwmstatus-Makefile
for convenience).

Comments and criticism is welcome.

I will try to push a change request to the suckless sites git repo if
nobody threats to neuter my hamster over the code I wrote...


Cheers,

Silvan

#define _BSD_SOURCE
#include unistd.h
#include stdbool.h
#include stdio.h
#include stdlib.h
#include stdarg.h
#include string.h
#include strings.h
#include sys/time.h
#include time.h
#include sys/types.h
#include sys/wait.h

#include X11/Xlib.h

char *tzargentina = America/Buenos_Aires;
char *tzutc = UTC;
char *tzberlin = Europe/Berlin;

static Display *dpy;

char *
smprintf(char *fmt, ...)
{
	va_list fmtargs;
	char *ret;
	int len;

	va_start(fmtargs, fmt);
	len = vsnprintf(NULL, 0, fmt, fmtargs);
	va_end(fmtargs);

	ret = malloc(++len);
	if (ret == NULL) {
		perror(malloc);
		exit(1);
	}

	va_start(fmtargs, fmt);
	vsnprintf(ret, len, fmt, fmtargs);
	va_end(fmtargs);

	return ret;
}

void
settz(char *tzname)
{
	setenv(TZ, tzname, 1);
}

int
parse_netdev(unsigned long long int *receivedabs, unsigned long long int *sentabs)
{
	char buf[255];
	char *datastart;
	static int bufsize;
	int rval;
	FILE *devfd;
	unsigned long long int receivedacc, sentacc;

	bufsize = 255;
	devfd = fopen(/proc/net/dev, r);
	rval = 1;

	// Ignore the first two lines of the file
	fgets(buf, bufsize, devfd);
	fgets(buf, bufsize, devfd);

	while (fgets(buf, bufsize, devfd)) {
	if ((datastart = strstr(buf, lo:)) == NULL) {
		datastart = strstr(buf, :);

		// With thanks to the conky project at http://conky.sourceforge.net/
		sscanf(datastart + 1, %llu  %*d %*d  %*d  %*d  %*d   %*d%*d   %llu,\
		   receivedacc, sentacc);
		*receivedabs += receivedacc;
		*sentabs += sentacc;
		rval = 0;
	}
	}

	fclose(devfd);
	return rval;
}

void
calculate_speed(char *speedstr, unsigned long long int newval, unsigned long long int oldval)
{
	double speed;
	speed = (newval - oldval) / 1024.0;
	if (speed  1024.0) {
	speed /= 1024.0;
	sprintf(speedstr, %.3f MB/s, speed);
	} else {
	sprintf(speedstr, %.2f KB/s, speed);
	}
}

char *
get_netusage(unsigned long long int *rec, unsigned long long int *sent)
{
	unsigned long long int newrec, newsent;
	newrec = newsent = 0;
	char downspeedstr[15], upspeedstr[15];
	static char retstr[42];
	int retval;

	retval = parse_netdev(newrec, newsent);
	if (retval) {
	fprintf(stdout, Error when parsing /proc/net/dev file.\n);
	exit(1);
	}

	calculate_speed(downspeedstr, newrec, *rec);
	calculate_speed(upspeedstr, newsent, *sent);

	sprintf(retstr, down: %s up: %s, downspeedstr, upspeedstr);

	*rec = newrec;
	*sent = newsent;
	return retstr;
}

char *
mktimes(char *fmt, char *tzname)
{
	char buf[129];
	time_t tim;
	struct tm *timtm;

	bzero(buf, sizeof(buf));
	settz(tzname);
	tim = time(NULL);
	timtm = localtime(tim);
	if (timtm == NULL) {
		perror(localtime);
		exit(1);
	}

	if (!strftime(buf, sizeof(buf)-1, fmt, timtm)) {
		fprintf(stderr, strftime == 0\n);
		exit(1);
	}

	return smprintf(%s, buf);
}

void
setstatus(char *str)
{
	XStoreName(dpy, DefaultRootWindow(dpy), str);
	XSync(dpy, False);
}

char *
loadavg(void)
{
	double avgs[3];

	if (getloadavg(avgs, 3)  0) {
		perror(getloadavg);
		exit(1);
	}

	return smprintf(%.2f %.2f %.2f, avgs[0], avgs[1], avgs[2]);
}

int
main(void)
{
	char *status;
	char *avgs;
	char *tmar;
	char *tmutc;
	char *tmbln;
	char *netstats;
	static unsigned long long int rec, sent;

	if (!(dpy = XOpenDisplay(NULL))) {
		fprintf(stderr, dwmstatus: cannot open display.\n);
		return 1;
	}

	parse_netdev(rec, sent);
	for (;;sleep(1)) {
		avgs = loadavg();
		tmar = mktimes(%H:%M, tzargentina);
		tmutc = mktimes(%H:%M, tzutc);
		tmbln = mktimes(KW %W %a %d %b %H:%M %Z %Y, tzberlin);
		netstats = get_netusage(rec, sent);

		status = smprintf([L: %s|N: %s|A: %s|U: %s|%s],
avgs, netstats, tmar, tmutc, tmbln);
		setstatus(status);
		free(avgs);
		free(tmar);
		free(tmutc);
		free(tmbln);
		free(status);
	}

	XCloseDisplay(dpy);

	return 0;
}

[dev] [st] [PATCH] Character size scaling factors

2013-07-28 Thread Eric Pruitt
The bounding boxes for characters can be scaled using cwscale and chscale
to scale the width and height respectively.
---
 TODO |1 -
 config.def.h |4 
 st.c |   20 +---
 3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/TODO b/TODO
index 4fc1346..794b71b 100644
--- a/TODO
+++ b/TODO
@@ -13,7 +13,6 @@ code  interface
 drawing
 ---
 * add diacritics support to xdraws()
-* add kerning configuration
 * make the font cache simpler
 * add hard width handling
 	* xft is reporting wrong width and height for characters
diff --git a/config.def.h b/config.def.h
index 9a3d2c8..8cb8804 100644
--- a/config.def.h
+++ b/config.def.h
@@ -9,6 +9,10 @@ static char font[] = Liberation Mono:pixelsize=12:antialias=false:autohint=fals
 static int borderpx = 2;
 static char shell[] = /bin/sh;
 
+/* Kerning / character bounding-box mutlipliers */
+float cwscale = 1.0;
+float chscale = 1.0;
+
 /*
  * word delimiter string
  *
diff --git a/st.c b/st.c
index 947373f..a238e27 100644
--- a/st.c
+++ b/st.c
@@ -76,6 +76,7 @@ char *argv0;
 #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg)
 #define IS_SET(flag) ((term.mode  (flag)) != 0)
 #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.tv_usec)/1000)
+#define CEIL(x) (((x) != (int) (x)) ? (x) + 1 : (x))
 
 #define VT102ID \033[?6c
 
@@ -2736,8 +2737,8 @@ xloadfonts(char *fontstr, int fontsize) {
 		die(st: can't open font %s\n, fontstr);
 
 	/* Setting character width and height. */
-	xw.cw = dc.font.width;
-	xw.ch = dc.font.height;
+	xw.cw = dc.font.width * cwscale;
+	xw.ch = dc.font.height * chscale;
 
 	FcPatternDel(pattern, FC_SLANT);
 	FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
@@ -2919,6 +2920,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 	Colour *fg, *bg, *temp, revfg, revbg;
 	XRenderColor colfg, colbg;
 	Rectangle r;
+	int oneatatime;
 
 	frcflags = FRC_NORMAL;
 
@@ -3027,6 +3029,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 		u8fs = s;
 		u8fblen = 0;
 		u8fl = 0;
+		oneatatime = font-width != xw.cw;
 		for(;;) {
 			u8c = s;
 			u8cblen = utf8decode(s, u8char);
@@ -3034,8 +3037,8 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 			bytelen -= u8cblen;
 
 			doesexist = XftCharExists(xw.dpy, font-match, u8char);
-			if(!doesexist || bytelen = 0) {
-if(bytelen = 0) {
+			if(oneatatime || !doesexist || bytelen = 0) {
+if(oneatatime || bytelen = 0) {
 	if(doesexist) {
 		u8fl++;
 		u8fblen += u8cblen;
@@ -3048,7 +3051,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 			winy + font-ascent,
 			(FcChar8 *)u8fs,
 			u8fblen);
-	xp += font-width * u8fl;
+	xp += CEIL(font-width * cwscale * u8fl);
 
 }
 break;
@@ -3057,8 +3060,11 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 			u8fl++;
 			u8fblen += u8cblen;
 		}
-		if(doesexist)
+		if(doesexist) {
+			if (oneatatime);
+continue;
 			break;
+		}
 
 		/* Search the font cache. */
 		for(i = 0; i  frclen; i++) {
@@ -3118,7 +3124,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 xp, winy + frc[i].font-ascent,
 (FcChar8 *)u8c, u8cblen);
 
-		xp += font-width;
+		xp += CEIL(font-width * cwscale);
 	}
 
 	/*


Re: [dev] Re: coreutils / moreutils - DC a directory counter

2013-07-28 Thread Paul Hoffman
On Fri, Jul 26, 2013 at 01:17:54AM +, Thorsten Glaser wrote:
 Calvin Morrison dixit:
 
 I was sick of ls | wc -l being so damned slow on large directories, so
 
 What, besides the printing and sorting, is the slow part anyway?
 Is it the VFS API or just the filesystem code?
 
 In the latter case… could workarounds exist? Someone asked this…
 http://fenski.pl/2013/07/looking-for-a-specific-fuse-based-filesystem/
 … on Planet Debian this night.

Summarized:

Their 100+ Perl and bash scripts are slow because they're opening files 
in a humongous directory.  They can't subdivide the directory because 
they're afraid that they will break the scripts when modifying them.

I just read something about using LD_PRELOAD for this.  Write a library 
that implements open(2), munging the file path and then calling the 
real open(2).  Then you just set LD_PRELOAD in the environment of the 
scripts and Bob's your uncle.

Don't shoot me, I have no idea whether that's a good idea or not!

Paul.

-- 
Paul Hoffman nkui...@nkuitse.com



Re: [dev] daemon for DWM

2013-07-28 Thread Anselm R Garbe
On 28 July 2013 19:02, Silvan Jegen s.je...@gmail.com wrote:
 I included some changes suggested by Markus in a rewrite of the netusage
 functions for dwmstatus (attached; including an adapted dwmstatus-Makefile
 for convenience).

 Comments and criticism is welcome.

 I will try to push a change request to the suckless sites git repo if
 nobody threats to neuter my hamster over the code I wrote...

Actually following this discussion I intent to make

  http://git.suckless.org/dwmstatus

world-writable as well. I think this would ease things wrt dwmstatus usages.

With this in mind we'd have sites, dextra and dwmstatus to be world-writable.

Best regards,
Anselm

PS: I'll perform the flag switch tonight.