From b97d025ee75300eec2a814775243ed02e0f9b2be Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Tue, 6 Aug 2024 01:11:05 +0200 Subject: [PATCH] clipboard -f implemented. --- clipboard/clipboard | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/clipboard/clipboard b/clipboard/clipboard index e998d6e..c969cf5 100755 --- a/clipboard/clipboard +++ b/clipboard/clipboard @@ -52,9 +52,23 @@ Equivalent to: B>B<(xsel -i -b) | xclip -i >>B cat | clipboard | cat +=head1 OPTIONS + +=over 4 + +=item B<-f> + +Run B every second. Only print output when it +changes. Similar to B. + +Select the text 'END' to stop. + + +=back + =head1 AUTHOR -Copyright (C) 2023 Ole Tange, +Copyright (C) 2023-2024 Ole Tange, http://ole.tange.dk and Free Software Foundation, Inc. @@ -87,6 +101,19 @@ B(1), B(1), B(1) #debug_log=/tmp/T-debug debug_log=/dev/null +if [ "-f" = "$1" ]; then + # run until c = END + while [ "$c" != "END" ]; do + c=$(clipboard 2>/dev/null) + if [ "$c" != "$last" ]; then + echo "$c" + last="$c" + fi + sleep 1 + done + exit 0 +fi + if tty -s ; then # STDIN is terminal # Don't care what STDOUT is