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

[feature-request] configuration option to bind selected text copy to somthing other than Ctrl+c based on focused application #99

Open
CsBigDataHub opened this issue Jan 10, 2025 · 6 comments
Labels
discussion enhancement New feature or request

Comments

@CsBigDataHub
Copy link

CsBigDataHub commented Jan 10, 2025

Since some applications like terminal, emacs or other similar editors do not use Ctrl+c to copy text, maybe we can create a config file with Application and copy keybinding.

We can then match configured application name to active window title to simulate application based copy keybinding.

Let me know if you need help to create this feature.

@CsBigDataHub CsBigDataHub changed the title [feature-request] configuration option to bind selected text copy to somthing other than Ctrl+c based on focued application [feature-request] configuration option to bind selected text copy to somthing other than Ctrl+c based on focused application Jan 10, 2025
@momokrono
Copy link
Collaborator

The idea is not bad, actually. I fear it will require a bit of code refactoring, but I could be done.

For Linux systems ideally it could access the second clipboard buffer (the one that gets filled while simply selecting some text and pasting it with the press of the middle mouse button or the scroll-wheel), so that we can bypass emulating ctrl+c completely since the buffer has been already filled by the user when selecting the text.

@CsBigDataHub
Copy link
Author

CsBigDataHub commented Jan 10, 2025

I think it is a better idea to access the clipboard rather than simulating Ctrl+c.
I would suggest user to copy the desired text [with application specific copy key-binding] and trigger Writing-tools. Writing-tools will access the top most clipboard entry and parses it to AI tools.

I think this approach would be cleaner and more adaptable across linux desktop environments.

@CsBigDataHub
Copy link
Author

CsBigDataHub commented Jan 10, 2025

@momokrono
Copy link
Collaborator

Pyperclip is the library already in use for this app.

Changing the default behavior by removing the ctrl+c/v emulation would not only be a major change but also make the app way less intuitive. For example, "chat mode" works exactly because there is no selected text, if we were to pick the top-most clipboard element we would completely lose this feature.

@CsBigDataHub
Copy link
Author

CsBigDataHub commented Jan 11, 2025

Yes, completely agree.

What about having 2 functions and 2 keybindings. One keybinding is configured to read from the clipboard. One keybinding opens writing tools in chat mode.

C+` - chat mode
C+~ - that is Ctrl+Shift+` - copies from clipboard and gives AI options.

This approach might be easier to manage. Thoughts?

@theJayTea
Copy link
Owner

Hey everyone! Sorry I wasn't able to research about this and reply earlier.

As @momokrono suggested, on Linux under X11, we should be able to access the second clipboard buffer directly, allowing Writing Tools to work on any selected text—even in editors like emacs & the terminal. Chat mode could still work too, since when you invoke Writing Tools without any text selected, the second clipboard buffer should be blank.

However, Wayland doesn't have a secondary selected text clipboard buffer, and by refactoring the code with the above implementation for Linux, we're essentially solidifying a lack of support for Wayland in the future.

For context, currently, Writing Tools only works on Wayland if you:

In the future, we could look into implementing KDE's global shortcuts API so things work smoothly on Wayland with KDE.

So I don't think it would be wise to refactor with some Xorg-specific functionality at the moment...

Let me know what you think!

Kind regards,
Jesai

@theJayTea theJayTea added discussion enhancement New feature or request labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants