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: Work in gnome-terminal or programs where paste shorcut isn't ctrl + v #201

Open
danielgiljara opened this issue Jul 29, 2022 · 18 comments

Comments

@danielgiljara
Copy link

Clipit doesn't work on terminal, where the paste shorcut is Ctrl + Shift + V.

@danielgiljara
Copy link
Author

danielgiljara commented Jul 30, 2022

I made the following patch for me and it works ok:
`diff --git a/src/main.c b/src/main.c
index 148753b..7e22c7d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -338,7 +338,7 @@ static void item_selected(GtkMenuItem menu_item, gpointer user_data) {
save_history();
/
Paste the clipboard contents automatically if enabled */
if (prefs.automatic_paste) {

  • gchar* cmd = g_strconcat("/bin/sh -c 'xdotool key ctrl+v'", NULL);
  • gchar* cmd = g_strconcat("/bin/bash -c 'wnd_focus=$(xdotool getwindowfocus); if [ $wnd_focus == 98566150 ]; then xdotool key ctrl+shift+v; else xdotool key ctrl+v; fi'", NULL);
    GPid pid;
    gchar **argv;
    g_shell_parse_argv(cmd, NULL, &argv, NULL);
    `

I close the ticket.

@danielgiljara
Copy link
Author

danielgiljara commented Aug 15, 2022

I used finally this patch to detect if the currently active window is gnome-terminal:
`
diff --git a/src/main.c b/src/main.c
index 148753b..ad7050a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -338,7 +338,7 @@ static void item_selected(GtkMenuItem menu_item, gpointer user_data) {
save_history();
/
Paste the clipboard contents automatically if enabled */
if (prefs.automatic_paste) {

  • gchar* cmd = g_strconcat("/bin/sh -c 'xdotool key ctrl+v'", NULL);
  • gchar* cmd = g_strconcat("/bin/bash -c 'wnd_focus=$(xdotool getwindowfocus); wnd_pid=$(xdotool getwindowpid $wnd_focus); wnd_gnome_terminal=$(ps -p $wnd_pid | grep gnome-terminal); if [ -z ""$wnd_gnome_terminal"" ]; then xdotool key ctrl+v; else xdotool key ctrl+shift+v; fi'", NULL);
    GPid pid;
    gchar **argv;
    g_shell_parse_argv(cmd, NULL, &argv, NULL);
    `

@Moini
Copy link

Moini commented Jan 21, 2023

Why did you close it? Please reopen. It would be useful to be able to select the paste command per application within clipit.

@Moini
Copy link

Moini commented Jan 21, 2023

(and not only for people who know how to program, but for everyone!)

@danielgiljara
Copy link
Author

Yes, I don't had to close it. I reopen.

@danielgiljara danielgiljara reopened this Jan 22, 2023
@danielgiljara
Copy link
Author

One question, did you found a manner to paste without xdotool?

@Moini
Copy link

Moini commented Jan 22, 2023

Thank you! No, I've currently deactivated the option to paste when clicking on an entry in the list, so I can choose the way how I paste.

@danielgiljara
Copy link
Author

What list? >.<

@danielgiljara
Copy link
Author

Do you want that I put a PR with the bash solution?

@Moini
Copy link

Moini commented Jan 22, 2023

I haven't tested it - how does it detect whether the target program is a terminal? I'm using Konsole, or sometimes Xfce-Terminal and others.

Optimally, I think it would offer a way to select programs that require a different pasting mechanism. If those can be autodetected, that would be cool, but I'm not sure that is possible?

@danielgiljara
Copy link
Author

The solution I proposed only detects when is gnome-terminal via bash, which is my case. Ideally it should use the X mechanism to paste, in this way it doesn't matter if is Ctrl + V or Ctrl + Shift + V or any other.

@danielgiljara danielgiljara changed the title Feature request: Work in terminal Feature request: Work in gnome-terminal or programs where paste shorcut isn't ctrl + v Jan 23, 2023
@Moini
Copy link

Moini commented Jan 23, 2023

I didn't know there was another way, that already provides the 'auto-detection'! Can this 'X mechanism' (probably provided by the xserver) be included somehow?

@danielgiljara
Copy link
Author

I've a patch, that checks via BASH scriptting (inside the command) if the process of the current window is the gnome-terminal and uses Control + Shift + V in that case. If you want I open a PR to give you that changes. It is not too elegant... but it works.

@danielgiljara
Copy link
Author

Hello Moini. Let me accces to publish a PR and I've you the code patched. With this gnome-terminal is supported.

@Moini
Copy link

Moini commented Apr 2, 2024

I'm using konsole :-(

@danielgiljara
Copy link
Author

danielgiljara commented Apr 5, 2024

Hello Moini. Please, think about it. If you accept my patch you can do work ClipIt in gnome also in kde, doing it more universal and more unified. It not hurts!!! :)

@Moini
Copy link

Moini commented Apr 5, 2024

I'm just a user, just like you @danielgiljara .

@danielgiljara
Copy link
Author

Ah, ok, in this case we can add the konsole command also if is different to ctrl-c like in gnome terminal. In this way we have ClipIt for all programs, and advice the author of Clipit to include these changes through a Pull Request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants