Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override clipboard command (on KDE/Wayland) #22

Open
rochacbruno opened this issue Apr 15, 2024 · 1 comment
Open

Override clipboard command (on KDE/Wayland) #22

rochacbruno opened this issue Apr 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@rochacbruno
Copy link

I really this app, this is the best option I have found for emoji picker on KDE, way better yhan the KDE integrated emoji picker.

However it is difficult to make it work on wayland, because wtype is not supported with some compositors and also I dont want to run ydotool as a service.

So my use case is simple:

  • I map Meta+. to efck
  • Once I select something it uses "wtype" (not really) to paste it to my clipboard
  • I hit ctrl+v

1 Fixing wtype compositor problem

Install CopyQ, it works on wayland and also X, and is good fit any DE.
On my Arch I dis with sudo pacman -S copyq

Copyq has a GUI interface, but we are only interested in the CLI it allows to add things to clipboard

As efck expects wtype and there is no way YET to customize the clipboard manager, we need to use a workaround

Create a file called wtype on your local bin ~/.local/bin/ or ~/bin

#!/usr/bin/env sh
copyq copy $1

chmod +x on it.

And that is it!

Map some keybinding to efck and it will call your script to add emoji selection to clipboard.

RFC

Make it possible to customize the clipboard command, so I can pass ["copyq", "copy"]

Btw: Thanks for this great tool!

@kernc
Copy link
Member

kernc commented Apr 16, 2024

Thanks for the kind words! 😊

So first of all, are you saying that if you check Force clipboard on the Options tab, it doesn't put the characters in your clipboard on KDE?

Because we use the Qt mechanism for that ...

efck/efck/output.py

Lines 45 to 57 in b695b8a

if res == 0 and not force_clipboard:
# Supposedly we're done
return
# Otherwise
_copy_to_clipboard(text)
def _copy_to_clipboard(text):
# Copy the emoji to global system clipboard
QApplication.instance().clipboard().setText(text, QClipboard.Mode.Clipboard)
assert QApplication.instance().clipboard().text(QClipboard.Mode.Clipboard) == text
logger.info('Text copied to clipboard: %s', text)

and that would indicate that QClipboard doesn't support Wayland. 🤔

Apparently due to complexity and workarounds, the window needs to be focused in order for clipboard to work.

Can you just for completeness try launching efck with export QT_QPA_PLATFORM=xcb?

But I agree, commands might need to be overridden. Of all the different options for it, inspired by your example, I'm leaning towards simply invoking well-known efck-chat-keyboard-typecmd and efck-chat-keyboard-copycmd if available in $PATH. What do you think?

@kernc kernc changed the title I found a workaround to make it work with clipboard on KDE/Wayland Override clipboard command (on KDE/Wayland) Apr 16, 2024
@kernc kernc added the enhancement New feature or request label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants