shithub: winwatch

Clone

clone: git://shithub.us/igor/winwatch gits://shithub.us/igor/winwatch
push: hjgit://shithub.us/igor/winwatch
patches to: igor@9lab.org

Last commit

5add9655 – Igor authored on 2021/11/01 19:14
install to $home/bin/$objtype

About

Slightly modified version of winwatch(1) that prints the window
id followed by a `|` symbol. That saves one to have to lookup
a window id when making/editing screenshots:

```
 % vcrop < /dev/wsys/9/window
 % topng < /dev/wsys/9/window > NeinNeinNein9999.png
```

Here the diff against base winwatch(1):

```diff
--- /sys/src/cmd/winwatch.c
+++ winwatch.c
@@ -97,7 +97,7 @@
 void
 refreshwin(void)
 {
-	char label[128], wctl[128], *tok[8];
+	char tag[128], label[128], wctl[128], *tok[8];
 	int i, fd, n, nr, nw, state;
 	static int mywinid = -1;
 	Dir *pd;
@@ -145,8 +145,9 @@
 				mwin += 8;
 				win = erealloc(win, mwin*sizeof(win[0]));
 			}
+			snprint(tag, sizeof(tag), "%2d|%s", n, label);
 			win[nw].n = n;
-			win[nw].label = estrdup(label);
+			win[nw].label = estrdup(tag);
 			win[nw].state = state;
 			win[nw].dirty = 1;
 			win[nw].r = Rect(0,0,0,0);
@@ -243,7 +244,8 @@
 	char buf[512], fname[128];
 	int n, fd;
 
-	snprint(buf, sizeof(buf), "%s", w.label);
+	if(readfile(buf, sizeof(buf), "/dev/wsys/%d/label", w.n) < 0)
+		return 0;
 	n = eenter(nil, buf, sizeof(buf), &m);
 	if(n <= 0)
 		return 0;
```