Compare commits

..

69 commits

Author SHA1 Message Date
Sergey Bugaev
16cf9d3fcc Update the man page
Mention the new file being read, and bump the date.
2026-08-06 11:55:44 +03:00
sentriz
7495661ad9
wl-paste: set CLIPBOARD_TYPE for the watch command
in --watch mode, expose the MIME type that wl-paste resolved for the paste to the spawned command via the CLIPBOARD_TYPE env var

    $ ./build/src/wl-paste --watch sh -c 'echo "state=$CLIPBOARD_STATE type=$CLIPBOARD_TYPE bytes=$(wc -c)"'
    state=data type=text/plain;charset=utf-8 bytes=226
    state=data type=image/png bytes=671

closes #296
2026-08-05 14:39:39 +01:00
Ariadna Vigo
ea2af55ffd
data/wl-clipboard.1: Fixed typo
'wl-cipboard' -> 'wl-clipboard' (line 200)
2026-08-01 23:12:28 +02:00
Sergey Bugaev
67a7b93789 Release wl-clipboard 2.3 2026-03-22 21:46:43 +03:00
Sergey Bugaev
a783546b94 Update libffi.wrap from WrapDB
Fixes building on new-ish GCC, see https://github.com/libffi/libffi/issues/760

Closes https://github.com/bugaevc/wl-clipboard/issues/278
2026-03-22 14:35:50 +03:00
Sergey Bugaev
123f52fed1 Bump copyright year 2026-03-22 14:35:50 +03:00
Sergey Bugaev
8da63985db Add a package spec example
Using some fictional syntax. Hopefully, this will help people see those
recommended optional dependencies listed more clearly.
2026-03-22 14:35:50 +03:00
rezky_nightky
c20a5fb1d5 fix: correct spelling issues across docs and helpers
- fix typos in CLIPBOARD_STATE man page entry (@data/wl-clipboard.1#152-160)
- clean up wording in fish and zsh completions (@completions/fish/wl-paste.fish#23-33, @completions/zsh/_wl-copy#16-29)
- correct comments in popup surface and file helpers (@src/types/popup-surface.c#81-95, @src/util/files.c#247-256)

Author: rezky_nightky <with.rezky@gmail.com>
Timestamp: 2025-12-01T18:50:09Z
Repository: wl-clipboard
Branch: master
Signing: GPG (989AF9F0)
Performance: 5 files, +5/-5 lines
2026-03-22 14:35:50 +03:00
anteater
ffa52935e1 files: read shared-mime-info globs2 file for mime extensions
This makes wl-paste mime detection work on systems with
shared-mime-info, which is used by most desktop programs over
mailcap's /etc/mime.types
2025-11-24 18:04:24 +03:00
Ron Nazarov
e8082035da Fix buffer overflow in infer_mime_type_from_contents
Return early if len == 0 and don't attempt to trim a nonexistent
newline.

Fixes https://github.com/bugaevc/wl-clipboard/issues/243
2025-11-24 17:31:15 +03:00
Aleksandr Mezin
927515b086 Set app id/class for the popup surface
This should allow other apps to detect wl-clipboard and implement
the necessary workarounds.
2025-11-24 16:19:33 +03:00
Sergey Bugaev
aaa927ee7f Respect $TMPDIR
Fixes https://github.com/bugaevc/wl-clipboard/issues/257
2025-04-24 16:49:07 +03:00
Vlad Zahorodnii
091d6028b5 Add support for ext-data-control-v1
The ext-data-control protocol is identical to the wlr-data-control
protocol, except that it is governed by the wayland-protocols now.
This change was tested in Plasma Wayland with and without the
ext_data_control_manager_v1 global.

Closes #242

Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-04-12 17:20:44 +03:00
Sergey Bugaev
424517085c Bump copyright year to 2025
As well as update the man page date.
2025-03-24 21:54:09 +03:00
Sergey Bugaev
1e50b65d5e Set CLIPBOARD_STATE=sensitive when x-kde-passwordManagerHint is set
See https://github.com/bugaevc/wl-clipboard/pull/204
2025-03-24 21:49:32 +03:00
Sergey Bugaev
e3c1b21ddd Add --sensitive flag to wl-copy
This currently sets the x-kde-passwordManagerHint, which is also set by
"some password managers", notably KWallet, and respected by Klipper.

Should a proper way to indicate a data source as sensitive appear, this
same option should be setting that, too.

See https://github.com/bugaevc/wl-clipboard/pull/214
Closes https://github.com/bugaevc/wl-clipboard/issues/177

Co-authored-by: Puck Meerburg <puck@puckipedia.com>
2025-03-24 21:42:25 +03:00
Florian Grabmeier
4f20741f66 Fix wrong flushing issue
Signed-off-by: Florian Grabmeier <flo.grabmeier@gmail.com>
2023-12-27 19:37:48 +01:00
Sergey Bugaev
abfd513ecc Fix assertion failure
If we try to paste when there is an offer that has no MIME types offered,
we'd fail when trying to report it to the user. Make sure to handle this
case explicitly, and report it the same way as there no being any offer
at all.
2023-09-29 14:48:22 +03:00
Sergey Bugaev
3eb912c274 Release wl-clipboard 2.2.1 2023-08-27 21:55:20 +03:00
Sergey Bugaev
6256adf6d9 Restore signal handlers in wl-copy before spawning children
We ignore SIGHUP and SIGPIPE in wl-copy itself, yet we want our child
processes, notably cat, to still get terminated if it receives SIGPIPE.
Signal handlers set to SIG_IGN unfortunately get inherited over exec, so
reset them before execing.

Fixes https://github.com/bugaevc/wl-clipboard/issues/190
2023-08-20 13:41:24 +03:00
Sergey Bugaev
8dbdefb77a Tweak binding interfaces further
- Also check for wl_seat version
- Fix parenthesizing in a macro
2023-08-20 13:13:13 +03:00
anteater
fcde402ed7 Do not abort when interfaces are older than expected
Instead, let consumers abort if the missing interface is a fatal problem.
2023-08-16 21:02:43 +00:00
Sergey Bugaev
c9964a555e Release wl-clipboard 2.2 2023-07-22 14:29:58 +03:00
Sergey Bugaev
8c91a6344b Tweak a couple of error messages 2023-07-22 14:19:39 +03:00
Sergey Bugaev
491a67ed69 Use wayland-protocols.wrap from WrapDB
This refers to a release rather than Git version and doesn't require
Git to be installed.

Related to https://github.com/bugaevc/wl-clipboard/issues/182
2023-07-16 18:44:39 +03:00
Sergey Bugaev
321836d559 Add Wayland as a Meson wrap subproject
Good things about this:

1. It should now be possible to build wl-clipboard without any system
   dependencies (other than Meson and the compiler toolchain), with
   everything coming from subprojects. Yet, this does not hurt the
   normal case of using system-provided dependencies for everything.

2. New enough Wayland (1.22.0, as opposed to 1.20.0 in the Meson WrapDB
   at the time of writing) now ships with a call to
   override_find_program('wayland-scanner'), so finding wayland-scanner
   works transparently.

Less than ideal things about this:

1. This requires us to specify default options (to disable Wayland
   tests, docs, and importantly DTD validation, which depends on
   libxml2) in our buildscript, not in the wrap file.

2. Wayland still doesn't ship expat and libffi as its own subprojects,
   so we have to ship the wraps in wl-clipboard alongside with Wayland
   itself.

3. If libwayland-client is found but wayland-scanner is not, the
   subproject gets built to get wayland-scanner, but our default options
   specified at dependency('wayland-client') call time are not respected
   and this throws an error about missing libxml2. This would be fixed
   if Meson allowed specifying default options in the wrap file.

Closes https://github.com/bugaevc/wl-clipboard/issues/182
2023-07-16 18:40:35 +03:00
Tristan Partin
518025b9e9 Remove unnecessary Meson arrays 2023-07-15 15:41:23 +03:00
Tristan Partin
cb82e5f1da Don't configure wayland-protocols tests 2023-07-15 15:41:23 +03:00
Tristan Partin
a4a3e8054b Use SPDX license string
This is what Meson expects you to use.
2023-07-15 15:41:23 +03:00
Artturin
80d9771381 Fix a warning
"format not a string literal and no format arguments [-Wformat-security]"

https://fedoraproject.org/wiki/Format-Security-FAQ
2023-07-15 15:36:07 +03:00
Lukas Lihotzki
6250cde91b Fix indentation in wl-copy.c 2023-07-13 00:36:33 +02:00
Sergey Bugaev
752820fb59 Bump the version to 2.2.0-rc2 2023-07-02 19:07:29 +03:00
Sergey Bugaev
ac7363c51c Tweak --help message
To make sure it fits on 80 columns.
2023-07-02 18:52:25 +03:00
Sergey Bugaev
5c4457da4c Mention getopt(3) features in the man page
Closes https://github.com/bugaevc/wl-clipboard/issues/131
2023-07-02 18:52:16 +03:00
Sergey Bugaev
8e2b84aa83 Tweak the man page
* Remove the mention of ASCII codes
* Add another BUG entry
2023-07-02 18:27:10 +03:00
Sergey Bugaev
8b68195ddc Add wayland-protocols as a Meson wrap subproject
Part of https://github.com/bugaevc/wl-clipboard/issues/182
2023-07-02 18:15:14 +03:00
Sergey Bugaev
4a5d9017b1 Tweak error message about missing shell
The most probable reason for this is wl-clipboard being built without
xdg-shell support, which is something we're trying to discourage, and
something that typically happens with self-built wl-clipboard binaries,
as opposed to distro-provided ones.

Instead of just adding a note (which would only be helpful if you're
actively aware of the decision to build wl-clipboard without xdg-shell),
print a specialized message explicitly pointing at missing xdg-shell at
build time as the root issue, and ask the user to rebuild wl-clipboard.
2023-07-02 18:10:01 +03:00
oxalica
a9c58833f0 Set CWD to root for background process
This releases the occupation of CWD, so that the mounting point of
removable devices containing it can be umounted.
2023-07-02 15:52:16 +03:00
Sergey Bugaev
c82266610e Strongly require protocol dependencies, with opt-out 2023-07-02 15:52:16 +03:00
Sergey Bugaev
84f16d447f Complain when launched with closed stdio fds
This will help us diagnose such cases, which otherwise manifest as
weird hangs and other bugs.

Closes https://github.com/bugaevc/wl-clipboard/issues/153
2023-05-04 00:39:45 +03:00
Sergey Bugaev
61d5fa34b4 Silence a warning 2023-05-04 00:38:29 +03:00
Sergey Bugaev
ea5c14e191 Bump the version to 2.2.0-rc1 2023-04-23 13:18:53 +03:00
Sergey Bugaev
985b9f4f23 Split and rewrite Markdown docs 2023-04-22 23:05:51 +03:00
Sergey Bugaev
12cb0e5947 Improve the wl-clipboard(1) man page 2023-04-22 21:30:56 +03:00
Sergey Bugaev
1270e06366 Fix a reentrancy-related regression
It is possible that the compositor gives our popup surface focus before
we ever commit a buffer. In that case, we run the rest of our logic
immediately, and popup_surface_init() knows not to proceed with creating
a buffer. However, that has regressed in commit
d66fb03313, where we started setting
popup_surface to NULL, but still checking for wl_surface being NULL to
detect that case. Fix this by also resetting self->wl_surface to NULL.

Fixes https://github.com/bugaevc/wl-clipboard/issues/174
2023-04-22 12:41:25 +03:00
Sergey Bugaev
95df4ef92b Tweak error messages further 2023-04-09 19:32:39 +03:00
Sergey Bugaev
e541d9a2d0 Implement support for xdg-activation
If someone happens to leave an activation token for wl-clipboard, it
will now use it to request its window to be activated.

Resolves https://github.com/bugaevc/wl-clipboard/issues/169

This should hopefully help with
https://github.com/bugaevc/wl-clipboard/issues/168
2023-04-09 19:10:09 +03:00
Sergey Bugaev
2de3fbf3d5 Implement support for gtk-shell
When the compositor supports it, wl-clipboard will use gtk-shell, the
semi-private protocol used by GTK, Mutter, and phoc, to ask the
compositor to raise the popup surface.

https://github.com/bugaevc/wl-clipboard/issues/169
2023-04-09 18:45:33 +03:00
Sergey Bugaev
7c0802dd25 Silence a Meson deprecation warning 2023-04-09 17:50:17 +03:00
Sergey Bugaev
01ad5cd524 Fix missing have_wp_primary_selection 2023-04-09 17:38:23 +03:00
Sergey Bugaev
06731b63bf Factor out protocols-specific part of meson.build 2023-04-09 17:30:54 +03:00
Sergey Bugaev
a3a55ec70a Improve various other error messages 2023-04-09 17:13:23 +03:00
Sergey Bugaev
4b2c4b241f Expand the "No suitable type" message
Let's list the inferred type (if any), and hint the user to use '--type'
if that's not the type they wanted.

Resolves https://github.com/bugaevc/wl-clipboard/issues/166
2023-04-09 17:12:47 +03:00
Sergey Bugaev
d8e2daf8e2 Diagnose Wayland connection issues
When the Wayland connection fails, let's print some useful info that may
help the user diagnose why it is failing. For instance, in case of
https://github.com/bugaevc/wl-clipboard/issues/114, this would print:

Failed to connect to a Wayland server: No such file or directory
Note: WAYLAND_DISPLAY is unset (using wayland-0)
Note: XDG_RUNTIME_DIR is set to /tmp/
Please check whether /tmp//wayland-0 socket exists and is accessible.
2023-04-09 16:28:36 +03:00
Sergey Bugaev
1e9f24f11c Destroy offers in wl-copy
...so that we don't leak them.

Fixes https://github.com/bugaevc/wl-clipboard/issues/69
2023-03-04 23:38:45 +03:00
Sergey Bugaev
d1278cd2ff Split an overly long line 2023-03-04 23:38:24 +03:00
Sergey Bugaev
d13ee70029 Run watch command on empty clipboard too
Connect its stdin to /dev/null, and set CLIPBOARD_STATE=nil.

Closes https://github.com/bugaevc/wl-clipboard/pull/93
Closes https://github.com/bugaevc/wl-clipboard/issues/109
2023-03-04 23:17:39 +03:00
Sergey Bugaev
56db369a3f Set CLIPBOARD_STATE=data for the watch command
This begins implementing the CLIPBOARD_STATE clipboard protocol outlined
in https://github.com/bugaevc/wl-clipboard/pull/93, and already
implemented by the SerenityOS clipboard tools.
2023-03-04 23:17:32 +03:00
Sergey Bugaev
4e678efa05 Extract running paste command into a function
This makes things a tiny bit cleaer, and will be useful for additionally
running the paste command when the offer is NULL.
2023-03-04 23:16:52 +03:00
Sergey Bugaev
7463d266cc Hardcode a couple more textual formats
While this approach obviously doesn't scale and we should probably
switch to a better one, adding these two lines is easy and it scratches
the particular itch.

Closes https://github.com/bugaevc/wl-clipboard/issues/73
2023-03-04 23:16:52 +03:00
Sergey Bugaev
dbaa684853 Unlink the temp file sooner
We only need the temp file to be present on the file system to run
xdg-mime on it. Once we have done that, we can unlink it and simply use
an fd to refer to it, seeking to the beginning each time.

This makes us more robust against wl-copy crashing (or getting killed),
in which case the file would be kept on the file system; this should no
longer be the case with this patch.

Related to https://github.com/bugaevc/wl-clipboard/pull/155
2023-03-04 20:18:51 +03:00
Sergey Bugaev
065d6da7d2 Update copyright years
Let's use a range of years instead of a single year.
2023-03-04 16:10:23 +03:00
Sergey Bugaev
86eacb7cd7 Prevent reentrancy in wl-paste --watch
It could happen that new offer comes in while we're in the middle of
trying to receive the previous one. This leads to issues and hangs,
since the logic is not prepared to handle reentrancy at all.

Commit 89cd9f9e43 has prevented this from
happening by immediately rejecting all but the very first offer, unless
the --watch mode is used. This makes sense, because unless the --watch
mode is used, we are indeed only interested in pasting once.

But this issue still manifested itself in the --watch mode. Fix that one
too, by not using wl_display_roundtrip() and thus not dispatching any
events in the middle of processing an offer.

Related to https://github.com/bugaevc/wl-clipboard/pull/133

Fixes https://github.com/bugaevc/wl-clipboard/issues/137
2023-03-04 15:54:10 +03:00
Sergey Bugaev
3b8c9a091a Ignore SIGPIPE in wl-copy
Fixes wl-copy dying under KDE.
2023-03-04 15:46:29 +03:00
Sergey Bugaev
6c77782829 Fix comment formatting 2023-03-04 15:46:13 +03:00
Nathan Ringo
d83a629822 Change wait() calls to waitpid()
This is a more correct thing to do, considering that there could
potentially be other child processes that wl-copy itself does not know
about, due to the current process spawning them before exec'ing the
wl-copy executable. In particular, it makes some sense to spawn a
process that produces clipboard contents (piped to stdin of wl-copy) as
a child of the process that becomes wl-copy.

Fixes #156
2023-01-09 11:54:00 +03:00
Julian Orth
89cd9f9e43 Ignore nested selection_callback calls in wl-paste
In `selection_callback`, if wl-paste uses a popup window,
`wl_display_roundtrip` is called. This can cause `selection_callback` to
be called again with a NULL offer since wl-paste has lost the keyboard
focus. Before this change this would cause wl-paste to abort the ongoing
paste by calling `exit(1)`.

Instead ignore all but the first selection_callback call except in watch
mode.
2022-06-12 09:08:43 -07:00
Ivan Molodetskikh
c206d79821 Release wl-clipboard 2.1 2022-03-19 15:12:00 +03:00
Sergey Bugaev
297ab2a6fd Fix a crash
During the wl_display_roundtrip() call, the popup surface could gain
focus a second time, which would cause do_set_selection() to be invoked
again. It would destroy the popup surface, which would cause the outer
do_set_selection() call to crash.

Fix this in two ways:
* Unset the callback before we perform roundtrip, to prevent any
  reentrancy.
* Check whether we (still) have a popup_surface instead of whether we
  need it; this way even if we end up without a popup surface for some
  other mysterious reason, we still won't segfault here.

Fixes https://github.com/bugaevc/wl-clipboard/issues/117
2021-07-20 21:06:21 +03:00
48 changed files with 1320 additions and 1037 deletions