clipboard -f implemented.

This commit is contained in:
Ole Tange 2024-08-06 01:11:05 +02:00
parent ab5791e738
commit b97d025ee7

View file

@ -52,9 +52,23 @@ Equivalent to: B<tee >>B<(xsel -i -b) | xclip -i >>B</dev/null; xsel -o -b>
cat | clipboard | cat
=head1 OPTIONS
=over 4
=item B<-f>
Run B<clipboard> every second. Only print output when it
changes. Similar to B<tail -f>.
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<tee>(1), B<xclip>(1), B<xsel>(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