GitHub - bugaevc/wl-clipboard: Command-line copy/paste utilities for Wayland
source link: https://github.com/bugaevc/wl-clipboard
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
wl-clipboard: Wayland clipboard utilities
This project implements two little Wayland clipboard utilities, wl-copy
and
wl-paste
, that let you easily copy data between the clipboard and Unix pipes,
sockets, files and so on.
Usage is as simple as:
# copy a simple text message $ wl-copy Hello world! # copy the list of files in Downloads $ ls ~/Downloads | wl-copy # copy an image file $ wl-copy < ~/Pictures/photo.png # paste to a file $ wl-paste > clipboard.txt # grep each pasted word in file source.c $ for word in $(wl-paste); do grep $word source.c; done # copy the previous command $ wl-copy "!!" # replace the current selection with the list of types it's offered in $ wl-paste --list-types | wl-copy
Although wl-copy
and wl-paste
are particularly optimized for plain text and
other textual content formats, they fully support content of arbitrary MIME
types. wl-copy
automatically infers the type of the copied content by running
xdg-mime(1)
on it. wl-paste
tries its best to pick a type to paste based on
the list of offered MIME types and the extension of the file it's pasting into.
If you're not satisfied with the type they pick or don't want to rely on this
implicit type inference, you can explicitly specify the type to use with the
--type
option.
Options
For wl-copy
:
-o
,--paste-once
Only serve one paste request and then exit. Unless a clipboard manager specifically designed to prevent this is in use, this has the effect of clearing the clipboard after the first paste, which is useful for copying sensitive data such as passwords. Note that this may break pasting into some clients, in particular pasting into XWayland windows is known to break when this option is used.-f
,--foreground
By default,wl-copy
forks and serves data requests in the background; this option overrides that behavior, causingwl-copy
to run in the foreground.-c
,--clear
Instead of copying anything, clear the clipboard so that nothing is copied.
For wl-paste
:
-n
,-no-newline
Do not append a newline character after the pasted clipboard content. This option is automatically enabled for non-text content types.-l
,--list-types
Instead of pasting the selection, output the list of MIME types it is offered in.
For both:
-p
,--primary
Use the "primary" clipboard instead of the regular clipboard. This uses the private GTK+ primary selection protocol. See the GNOME Wiki page on primary selection under Wayland for more details.-t mime/type
,--type mime/type
Override the inferred MIME type for the content. Forwl-copy
this option controls which typewl-copy
will offer the content as. Forwl-paste
it controls which of the offered typeswl-paste
will request the content in. In addition to specific MIME types such as image/png,wl-paste
also accepts generic type names such as text and image which make it automatically pick some offered MIME type that matches the given generic name.
Building
wl-clipboard is a simple Meson project, so building it is just:
# clone $ git clone https://github.com/bugaevc/wl-clipboard.git $ cd wl-clipboard # build $ meson build $ cd build $ ninja # install $ sudo ninja install
wl-clipboard only supports Linux (though patches to add BSD support are
welcome!). The only manadatory dependency is the wayland-client
library (try
package named wayland-devel
or libwayland-dev
).
Optional dependencies for building:
wayland-scanner
for primary selection support using the bundled gtk-primary-selection protocolwayland-protocols
(version 1.12 or later) for xdg-shell support (otherwise it won't run under compositors lackingwl_shell
support, see the issue #2)
Optional dependencies for running:
xdg-mime
for content type inference inwl-copy
(try package namedxdg-utils
)/etc/mime.types
file for type inference inwl-paste
(try package namedmime-support
ormailcap
)
License
wl-clipboard is free software, available under the GNU General Public License version 3 or later.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK