shithub: zuke

Download patch

ref: 39fa000535052d34d481f6484a5df1adcfa30948
parent: 3ef22d5f5699f64f6d89fea1eaeb75b892633af5
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Feb 21 06:11:40 EST 2016

higher prio; raise relbuf size; resize cover; place cover on bottom right

--- a/zuke.c
+++ b/zuke.c
@@ -15,7 +15,7 @@
 	Cstop,
 	Ctoggle,
 
-	Relbufsz = 8192,
+	Relbufsz = 32768,
 };
 
 static Meta *pl;
@@ -47,7 +47,7 @@
 {
 	char tmp[256];
 	Point p, sp;
-	Rectangle sel;
+	Rectangle sel, r;
 	int i;
 
 	if(new && getwindow(display, Refnone) < 0)
@@ -56,9 +56,6 @@
 		draw(screen, screen->r, cola, nil, ZP);
 	sp.x = sp.y = 0;
 
-	if(cover != nil)
-		draw(screen, screen->r, cover, nil, ZP);
-
 	p.x = screen->r.min.x + 2;
 	p.y = screen->r.min.y + 2;
 	scrollsz = Dy(screen->r) / f->height - 1;
@@ -89,6 +86,18 @@
 		p.y += f->height;
 	}
 
+	if(cover != nil){
+		r = screen->r;
+		r.min.x = r.max.x - cover->r.max.x - 8;
+		r.min.y = r.max.y - cover->r.max.y - 8;
+		draw(screen, r, display->black, nil, ZP);
+		r.min.x += 4;
+		r.min.y += 4;
+		r.max.x -= 4;
+		r.max.y -= 4;
+		draw(screen, r, cover, nil, ZP);
+	}
+
 	flushimage(display, 1);
 }
 
@@ -95,7 +104,7 @@
 static void
 coverload(void *m_)
 {
-	int p[2], fd, pid;
+	int p[2], p2[2], fd, pid, pid2;
 	char *prog;
 	Meta *m;
 
@@ -122,10 +131,8 @@
 
 	pipe(p);
 	if((pid = rfork(RFPROC|RFFDG|RFREND|RFNOTEG)) == 0){
-		dup(fd, 0);
-		dup(p[0], 1);
-		close(fd);
-		close(p[0]);
+		dup(fd, 0); close(fd);
+		dup(p[0], 1); close(p[0]);
 		close(p[1]);
 		execl(prog, prog, "-9t", nil);
 		sysfatal("execl: %r");
@@ -132,12 +139,25 @@
 	}
 	close(fd);
 	close(p[0]);
-	if(pid > 0){
-		cover = readimage(display, p[1], 0);
-		postnote(PNGROUP, pid, "kill");
-		redraw(screen, 0);
+
+	pipe(p2);
+	if((pid2 = rfork(RFPROC|RFFDG|RFREND|RFNOTEG)) == 0){
+		dup(p[1], 0); close(p[1]);
+		dup(p2[0], 1); close(p2[0]);
+		close(p2[1]);
+		execl("/bin/resize", "/bin/resize", "-x128", nil);
+		sysfatal("execl: %r");
 	}
 	close(p[1]);
+	close(p2[0]);
+
+	if(pid > 0 && pid2 > 0){
+		cover = readimage(display, p2[1], 0);
+		redraw(screen, 0);
+	}
+	postnote(PNGROUP, pid, "kill");
+	postnote(PNGROUP, pid2, "kill");
+	close(p2[1]);
 }
 
 static void
@@ -183,9 +203,9 @@
 
 	pcurplaying = player->pcur;
 	redraw(screen, 0);
-	threadcreate(coverload, &pl[pcurplaying], 4096);
+	proccreate(coverload, &pl[pcurplaying], 4096);
 
-	while((n = readn(p[1], buf, Relbufsz)) > 0){
+	while((n = read(p[1], buf, Relbufsz)) > 0){
 		c = nbrecvul(player->ctl);
 		if(c == Cstop)
 			goto stop;
@@ -381,7 +401,7 @@
 void
 threadmain(int argc, char **argv)
 {
-	int inv, oldpcur;
+	int inv, fd, oldpcur;
 	Player *player;
 	Rune key;
 	Mouse m;
@@ -392,6 +412,7 @@
 		{ nil, &key, CHANRCV },
 		{ nil, nil,  CHANEND },
 	};
+	char tmp[256];
 
 	inv = 0;
 	ARGBEGIN{
@@ -430,6 +451,12 @@
 	pcurplaying = -1;
 	player = nil;
 	threadsetname("zuke");
+
+	snprint(tmp, sizeof(tmp), "/proc/%d/ctl", getpid());
+	if((fd = open(tmp, OWRITE)) >= 0){
+		fprint(fd, "pri 13\n");
+		close(fd);
+	}
 
 	redraw(screen, 1);