shithub: watch

Download patch

ref: 70678753c46e5d223e6db1e197030e36407eb642
parent: 73875dcb86ab049fe2c5e4f5939db05d83891d2e
author: kvik <vp@kvik.link>
date: Tue Jun 11 05:25:06 EDT 2019

allow specifying -t period in miliseconds


--- a/watch.c
+++ b/watch.c
@@ -173,6 +173,7 @@
 main(int argc, char *argv[])
 {
 	int t;
+	char *unit;
 	char *cmd;
 
 	cmd = "mk";
@@ -180,7 +181,12 @@
 	case 'e':
 		eadd(EARGF(usage())); break;
 	case 't':
-		if((t = strtol(EARGF(usage()), nil, 10)) > 0)
+		t = strtol(EARGF(usage()), &unit, 10);
+		if(t < 0)
+			t = -t;
+		if(unit != nil && strncmp(unit, "ms", 2) == 0)
+			period = t;
+		else
 			period = t*1000;
 		break;
 	case 'G':
--- a/watch.man
+++ b/watch.man
@@ -32,9 +32,12 @@
 defaults to
 .BR \e.[chsy]$ 
 .TP
-.BI -t sec
-Sets the polling period;
-one second by default.
+.BI -t period
+Sets the polling
+.IR period
+in seconds (one second by default).
+\'ms' can be appended to the value
+to specify time in miliseconds.
 .TP
 .B -G
 Prevents regrouping to the parent