shithub: bar

Download patch

ref: 9bcc44edd377db1328f0f9b45810c6c42e17c5b4
parent: fcdc01e594cd5f3b27c571303b6ef4efd72c1eeb
parent:
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Jan 27 02:32:15 EST 2021

use display->image instead of reading /dev/screen

--- a/bar.c	Wed Jan 27 02:20:48 2021
+++ b/bar.c	Wed Jan 27 02:32:15 2021
@@ -64,21 +64,13 @@
 static void
 place(void)
 {
-	int fd, n, w, h, minx, miny, maxx, maxy;
-	char t[61], *a[5];
+	int w, h, minx, miny, maxx, maxy;
+	char t[64];
 	static int ow, oh;
 
 	fprint(wctl, bottom ? "bottom" : "top");
-
-	if((fd = open("/dev/screen", OREAD)) < 0)
-		return;
-	n = read(fd, t, sizeof(t)-1);
-	close(fd);
-	t[sizeof(t)-1] = 0;
-	if(n != sizeof(t)-1 || tokenize(t, a, 5) != 5)
-		return;
-	w = atoi(a[3]);
-	h = atoi(a[4]);
+	w = Dx(display->image->r);
+	h = Dy(display->image->r);
 
 	if(ow != w || oh != h || owidth < width){
 		if(pos[0] == 't' || pos[1] == 't'){