summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-10-18 14:48:29 -0400
committerJune McEnroe <june@causal.agency>2021-10-18 14:48:29 -0400
commit0fc730ec8e058607b05185e1a36b22615ffbae40 (patch)
tree4468b050f4d43432d1ad37c8f065460e11d34431
parentAdd ptee -t to output media copy at an interval (diff)
downloadsrc-0fc730ec8e058607b05185e1a36b22615ffbae40.tar.gz
src-0fc730ec8e058607b05185e1a36b22615ffbae40.zip
Add shotty -t to animate (crudely) between snapshots
-rw-r--r--bin/man1/shotty.17
-rw-r--r--bin/shotty.l25
2 files changed, 31 insertions, 1 deletions
diff --git a/bin/man1/shotty.1 b/bin/man1/shotty.1
index 0a3bd127..18cf52f6 100644
--- a/bin/man1/shotty.1
+++ b/bin/man1/shotty.1
@@ -12,6 +12,7 @@
 .Op Fl b Ar bg
 .Op Fl f Ar fg
 .Op Fl h Ar rows
+.Op Fl t Ar ms
 .Op Fl w Ar cols
 .Op Ar file
 .
@@ -82,6 +83,12 @@ Hide the cursor.
 Copy the terminal size
 from the current terminal.
 .
+.It Fl t Ar ms
+Animate between snapshots
+at an interval of
+.Ar ms
+milliseconds.
+.
 .It Fl w Ar cols
 Set the terminal width.
 The default is 80.
diff --git a/bin/shotty.l b/bin/shotty.l
index 3d1d50c0..93e7f0ee 100644
--- a/bin/shotty.l
+++ b/bin/shotty.l
@@ -507,8 +507,9 @@ int main(int argc, char *argv[]) {
 	bool debug = false;
 	bool size = false;
 	bool hide = false;
+	int interval = 0;
 
-	for (int opt; 0 < (opt = getopt(argc, argv, "Bb:df:h:insw:"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "Bb:df:h:inst:w:"));) {
 		switch (opt) {
 			break; case 'B': bright = true;
 			break; case 'b': defaultBg = atoi(optarg);
@@ -518,6 +519,7 @@ int main(int argc, char *argv[]) {
 			break; case 'i': colors = true;
 			break; case 'n': hide = true;
 			break; case 's': size = true;
+			break; case 't': interval = atoi(optarg);
 			break; case 'w': cols = atoi(optarg);
 			break; default:  return EX_USAGE;
 		}
@@ -559,4 +561,25 @@ int main(int argc, char *argv[]) {
 	}
 	if (hide) mode &= ~Cursor;
 	if (!mc) html();
+
+	if (interval) {
+		printf(
+			Q(
+				<script>
+				let frames = document.querySelectorAll("pre");
+				let frame = 0;
+				function animate() {
+					for (let i = 0; i < frames.length; ++i) {
+						frames[i].hidden = (i != frame);
+					}
+					frame++;
+					if (frame == frames.length) frame = 0;
+				}
+				animate();
+				setInterval(animate, %d);
+				</script>
+			),
+			interval
+		);
+	}
 }
mp;id=f4d06c101fd0a66d01ca964004a7bba5e63e01ae&follow=1'>contrib/palaver: Only allow HTTPSJune McEnroe 2020-08-25Support the pounce_env rc variableJune McEnroe 2020-08-25Remove deprecated option namesJune McEnroe 2020-08-25Document configuration and data file searchJune McEnroe 2020-08-24Use dataOpen for save fileJune McEnroe 2020-08-24Use configOpen to load localCAJune McEnroe 2020-08-24Use configPath to load client cert/privJune McEnroe 2020-08-24Use configOpen in getopt_configJune McEnroe 2020-08-24Import xdg.c from catgirlJune McEnroe 2020-08-23Replace “RAND_bytes” by “getentropy”Issam E. Maghni 2020-08-16contrib/palaver: Add no message preview flagsJune McEnroe 2020-08-13contrib/palaver: Don't set channel for PMsJune McEnroe 2020-08-13Fix unintended interception of NICK after registrationJune McEnroe 2020-08-12Add Additional Components section to READMEJune McEnroe 2020-08-12Document -L / palaver optionJune McEnroe 2020-08-11contrib/palaver: Document service configurationJune McEnroe 2020-08-11contrib/palaver: Add install target and rc scriptJune McEnroe 2020-08-11contrib/palaver: Implement command and notificationsJune McEnroe