Skip to content

Extraneous output on Wayland for paste() from an empty clipboard #280

Description

@melwyncarlo

On Linux (Ubuntu) Wayland display system, when the pyperclip.paste() function is called and when the clipboard is empty, a message is printed on the screen: Nothing is copied

This comes from either of the two code statements:

  1. https://github.com/bugaevc/wl-clipboard/blob/aaa927ee7f7d91bcc25a3b68f60d01005d3b0f7f/src/wl-paste.c#L267
            bail("Nothing is copied");
  1. https://github.com/bugaevc/wl-clipboard/blob/aaa927ee7f7d91bcc25a3b68f60d01005d3b0f7f/src/wl-paste.c#L227
        bail("Nothing is copied");

The bail() macro function is defined in https://github.com/bugaevc/wl-clipboard/blob/aaa927ee7f7d91bcc25a3b68f60d01005d3b0f7f/src/util/misc.h#L25 as:

#define bail(message) do { fprintf(stderr, message "\n"); exit(1); } while (0)

I tried the following, but to no avail:

import os
import contextlib
with contexlib.redirect_stdout(open(os.devnull, "w")) and contexlib.redirect_stderr(open(os.devnull, "w")):
    ...

I believe this is because the printing is done from an external program.
This can however be suppressed by redirecting stderr to an anonymous pipe, just as it was done for stdout.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions