How to copy in wayland?

I recently have switched to wayland, and xsel copy stop working, thus I need to use wl-clipboard, and don’t know how to make emacs follow the new rules of the game.

1 Like

In which direction are you trying to copy, out of (Doom) Emacs or into Emacs?

Generally anything copied from say a browser automatically enters the clipboard and can be pasted into Emacs via p. You can have even more control with SPC i y.

Both, like with X11 @fosskers

When you y y on a line in Emacs, and you then able to Ctrl-v that into a browser’s URL bar?

  1. What kind of grammar is this? 2. Tried and did not work.

y y is the command in Doom Emacs to copy a line to the clipboard. SPC i y let’s you paste something from a list of recent clipboard additions. Do you use Doom or normal Emacs?

This is Doom Emacs’s discourse forum, so I am using Doom Emacs.

Can you elaborate more about your use case?

Needing a specific program to handle clipboard seems like an advanced method as copying and pasting among Emacs and other applications just work OOTB most of the time on popular desktop environments.

I am using KDE Plasma (Wayland) in OpenSUSE Leap 15.5. And if for most desktops you mean X11 DE, you are right, but xsel and xclip don’t work in wayland.

I may have forgot to note that I am running emacs in tty mode?

You should have mentioned that from the very beginning, now it’s a matter of converting xsel commands to wl-clipboard ones without Emacs-specific things.

I have never used xsel, but here are wl-clipboard elisp wrappers I can think of:


; Copying
(call-process "wl-copy"
              nil
              nil
              nil
              "--"
              (buffer-substring (region-beginning) (region-end)))

; Pasting
(insert
 (with-temp-buffer
   (call-process "wl-paste" nil t nil "--no-newline")
   (buffer-string)))


Are you sure that it runs with the module tty?

Just tested it, and they aren’t working. If I try to paste something it only pastes whatever was in the clipboard at startup time

That’s… weird, IWOMM (Plasma 5.27 Wayland, emacs -nw).

I should I said that I put that in my ~/.config/doom/config.el

No… please put it in an interactive function like (defun my-wayland-copy ()....

What did you do with xsel, now just replace with the equivalent wl-copy/paste command.

I have been using the xclip package since my X11 days. Updated when I switched to Wayland. Now it uses the wl-clipboard tool. Works fine both with Doom GUI or no-GUI (i.e. -nw):

(use-package! xclip
  :config
  (setq xclip-program "wl-copy")
  (setq xclip-select-enable-clipboard t)
  (setq xclip-mode t)
  (setq xclip-method (quote wl-copy)))

hth

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.