clipboard: Copy to/from X clipboard.
This commit is contained in:
parent
787c137b8a
commit
ed6f1078ff
21
Makefile
21
Makefile
|
@ -1,15 +1,16 @@
|
||||||
CMD = 2grep 2search blink burncpu bwlimit drac duplicate-packets em \
|
CMD = 2grep 2search blink burncpu bwlimit clipboard drac \
|
||||||
emoticons encdir fanspeed field find-first-fail find-optimal \
|
duplicate-packets em emoticons encdir fanspeed field \
|
||||||
forever fxkill G gitnext gitundo goodpasswd histogram Loffice \
|
find-first-fail find-optimal forever fxkill G gitnext gitundo \
|
||||||
mtrr mirrorpdf neno not off pdfman pidcmd pidtree plotpipe \
|
goodpasswd histogram Loffice mtrr mirrorpdf neno not off \
|
||||||
puniq ramusage rand rclean rina rn rrm seekmaniac shython \
|
pdfman pidcmd pidtree plotpipe puniq ramusage rand rclean \
|
||||||
sound-reload splitvideo stdout swapout T teetime timestamp \
|
rina rn rrm seekmaniac shython sound-reload splitvideo stdout \
|
||||||
tracefile transpose upsidedown vid w4it-for-port-open \
|
swapout T teetime timestamp tracefile transpose upsidedown \
|
||||||
whitehash wifi-reload wssh youtube-lbry ytv yyyymmdd
|
vid w4it-for-port-open whitehash wifi-reload wssh \
|
||||||
|
youtube-lbry ytv yyyymmdd
|
||||||
|
|
||||||
all: 2search/2grep.1 2search/2search.1 blink/blink.1 \
|
all: 2search/2grep.1 2search/2search.1 blink/blink.1 \
|
||||||
burncpu/burncpu.1 bwlimit/bwlimit.1 drac/drac.1 \
|
burncpu/burncpu.1 bwlimit/bwlimit.1 clipboard/clipboard.1 \
|
||||||
encdir/encdir.1 fanspeed/fanspeed.1 field/field.1 \
|
drac/drac.1 encdir/encdir.1 fanspeed/fanspeed.1 field/field.1 \
|
||||||
find-first-fail/find-first-fail.1 find-optimal/find-optimal.1 \
|
find-first-fail/find-first-fail.1 find-optimal/find-optimal.1 \
|
||||||
G/G.1 gitnext/gitnext.1 gitundo/gitundo.1 \
|
G/G.1 gitnext/gitnext.1 gitundo/gitundo.1 \
|
||||||
goodpasswd/goodpasswd.1 histogram/histogram.1 \
|
goodpasswd/goodpasswd.1 histogram/histogram.1 \
|
||||||
|
|
109
clipboard/clipboard
Executable file
109
clipboard/clipboard
Executable file
|
@ -0,0 +1,109 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
: <<=cut
|
||||||
|
=encoding utf8
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
clipboard - copy to or from X clipboard
|
||||||
|
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
B<clipboard>
|
||||||
|
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
B<clipboard> can be used in 3 ways.
|
||||||
|
|
||||||
|
=head2 End of a pipe - save to clipboard
|
||||||
|
|
||||||
|
If placed last in a pipe B<clipboard> will take standard output from a
|
||||||
|
command and save it to the clipboard.
|
||||||
|
|
||||||
|
Equivalent to: B<cat | xsel -i -b>
|
||||||
|
|
||||||
|
=head3 Example
|
||||||
|
|
||||||
|
cat file | clipboard
|
||||||
|
|
||||||
|
=head2 Start of a pipe - paste the clipboard
|
||||||
|
|
||||||
|
If placed first in a pipe B<clipboard> will paste content of the
|
||||||
|
clipboard to standard output.
|
||||||
|
|
||||||
|
Equivalent to: B<xsel -o -b>
|
||||||
|
|
||||||
|
=head3 Example
|
||||||
|
|
||||||
|
clipboard | cat
|
||||||
|
|
||||||
|
=head2 In the middle of a pipe - save and paste
|
||||||
|
|
||||||
|
If placed in the middle of a pipe B<clipboard> will copy standard
|
||||||
|
output from a command and copy it to the clipboard and pass on the
|
||||||
|
standard output.
|
||||||
|
|
||||||
|
Equivalent to: B<xsel -i -b; xsel -o -b>
|
||||||
|
|
||||||
|
=head3 Example
|
||||||
|
|
||||||
|
cat | clipboard | cat
|
||||||
|
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Copyright (C) 2023 Ole Tange,
|
||||||
|
http://ole.tange.dk and Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
|
||||||
|
=head1 LICENSE
|
||||||
|
|
||||||
|
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
at your option any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
B<xsel>(1), B<tee>(1), B<cat>(1)
|
||||||
|
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
#debug_log=/tmp/T-debug
|
||||||
|
debug_log=/dev/null
|
||||||
|
|
||||||
|
if tty -s ; then
|
||||||
|
# STDIN is terminal
|
||||||
|
# Don't care what STDOUT is
|
||||||
|
# clipboard | cat => paste clipboard
|
||||||
|
# clipboard => paste clipboard
|
||||||
|
echo xsel -o -b >> $debug_log
|
||||||
|
xsel -o -b
|
||||||
|
else
|
||||||
|
if [ -t 1 ] ; then
|
||||||
|
# STDOUT = terminal
|
||||||
|
# cat | clipboard => copy to clipboard
|
||||||
|
echo xsel -i -b >> $debug_log
|
||||||
|
xsel -i -b
|
||||||
|
else
|
||||||
|
# STDOUT redir'ed
|
||||||
|
# cat | clipboard | cat => copy and forward clipboard
|
||||||
|
echo xsel tee >> $debug_log
|
||||||
|
tee >(xsel -i -b)
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in a new issue