Emote icon indicating copy to clipboard operation
Emote copied to clipboard

Pasting in Wayland redux

Open protist opened this issue 1 year ago • 20 comments
trafficstars

I know Wayland has been discussed here before, but I think there is a way to paste emoji.

Emote is already using wl-clipboard, specifically wl-copy to copy the emoji. Hence, it should be straightforward to use wl-paste from the same repository.

Having said that, I tried messing with Emote's code, but I couldn't get it to work. I tried variations on the following.

--- a/emote/picker.py	2024-05-17 20:40:02.000000000 +1000
+++ b/emote/picker.py	2024-06-19 22:28:28.977476352 +1000
@@ -648,9 +648,13 @@
 
         self.destroy()
 
+        time.sleep(0.15)
         if not config.is_wayland:
-            time.sleep(0.15)
             os.system("xdotool key ctrl+v")
+        else:
+            os.system("wl-paste")
 
     def add_emoji_to_recent(self, emoji):
         user_data.update_recent_emojis(emoji)

but nothing ever pasted. FWIW I don't entirely understand how the code works here. Even in X11, isn't the "ctrl+v" operating while Emote is still in the foreground? I tried increasing the sleep, but this just delays how long the Emote window stays open.

Another option could be using ydotool, e.g. pasting with

+            os.system("ydotool key 29:1 47:1 47:0 29:0")

or even better, bypassing the clipboard and directly

+            os.system("ydotool type " + emoji)

However, neither of these worked for me either.

protist avatar Jun 19 '24 12:06 protist